Skip to content

Commit 65a78c3

Browse files
author
Matthew Fisher
committed
test(integration): add client.json tests
1 parent 5e76335 commit 65a78c3

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/integration_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,55 @@
33
package tests
44

55
import (
6+
"encoding/json"
7+
"io/ioutil"
8+
"os/user"
9+
"path"
610
"testing"
711

812
"github.com/deis/deis/tests/utils"
913
)
1014

15+
const clientJsonFilePath string = ".deis/client.json"
16+
1117
var (
1218
gitCloneCmd = "if [ ! -d {{.ExampleApp}} ] ; then git clone https://github.com/deis/{{.ExampleApp}}.git ; fi"
1319
gitRemoveCmd = "git remote remove deis"
1420
gitPushCmd = "git push deis master"
1521
)
1622

23+
// Client represents the client data structure in ~/.deis/client.json
24+
type Client struct {
25+
Controller string `json:"controller"`
26+
Username string `json:"username"`
27+
Token string `json:"token"`
28+
}
29+
1730
func TestGlobal(t *testing.T) {
1831
params := utils.GetGlobalConfig()
1932
utils.Execute(t, authRegisterCmd, params, false, "")
33+
clientTest(t, params)
2034
utils.Execute(t, keysAddCmd, params, false, "")
2135
}
36+
37+
func clientTest(t *testing.T, params *utils.DeisTestConfig) {
38+
user, err := user.Current()
39+
if err != nil {
40+
t.Fatal(err)
41+
}
42+
data, err := ioutil.ReadFile(path.Join(user.HomeDir, clientJsonFilePath))
43+
if err != nil {
44+
t.Fatal(err)
45+
}
46+
client := &Client{}
47+
json.Unmarshal(data, &client)
48+
if client.Token == "" {
49+
t.Error("token not present in client.json")
50+
}
51+
if client.Controller == "" {
52+
t.Error("controller endpoint not present in client.json")
53+
}
54+
if client.Username == "" {
55+
t.Error("username not present in client.json")
56+
}
57+
}

0 commit comments

Comments
 (0)