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