-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathintegration_test.go
More file actions
61 lines (54 loc) · 1.39 KB
/
integration_test.go
File metadata and controls
61 lines (54 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// +build integration
package tests
import (
"encoding/json"
"io/ioutil"
"os"
"os/user"
"path"
"testing"
"github.com/deis/deis/tests/utils"
)
var (
gitCloneCmd = "if [ ! -d {{.ExampleApp}} ] ; then git clone https://github.com/deis/{{.ExampleApp}}.git ; fi"
gitRemoveCmd = "git remote remove deis"
gitPushCmd = "git push deis master"
)
// Client represents the client data structure in ~/.deis/client.json
type Client struct {
Controller string `json:"controller"`
Username string `json:"username"`
Token string `json:"token"`
}
func TestGlobal(t *testing.T) {
params := utils.GetGlobalConfig()
utils.Execute(t, authRegisterCmd, params, false, "")
clientTest(t, params)
utils.Execute(t, keysAddCmd, params, false, "")
}
func clientTest(t *testing.T, params *utils.DeisTestConfig) {
user, err := user.Current()
if err != nil {
t.Fatal(err)
}
profile := os.Getenv("DEIS_PROFILE")
if profile == "" {
profile = "client"
}
clientJsonFilePath := ".deis/" + profile + ".json"
data, err := ioutil.ReadFile(path.Join(user.HomeDir, clientJsonFilePath))
if err != nil {
t.Fatal(err)
}
client := &Client{}
json.Unmarshal(data, &client)
if client.Token == "" {
t.Error("token not present in client.json")
}
if client.Controller == "" {
t.Error("controller endpoint not present in client.json")
}
if client.Username == "" {
t.Error("username not present in client.json")
}
}