github.com/sbuss/deis@v1.6.1/tests/config_test.go (about) 1 // +build integration 2 3 package tests 4 5 import ( 6 "io/ioutil" 7 "testing" 8 9 "github.com/deis/deis/tests/utils" 10 ) 11 12 var ( 13 configListCmd = "config:list --app={{.AppName}}" 14 configSetCmd = "config:set FOO=讲台 --app={{.AppName}}" 15 configSet2Cmd = "config:set FOO=10 --app={{.AppName}}" 16 configSet3Cmd = "config:set POWERED_BY=\"the Deis team\" --app={{.AppName}}" 17 configSetBuildpackCmd = "config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-go#98f37cc --app={{.AppName}}" 18 configUnsetCmd = "config:unset FOO --app={{.AppName}}" 19 ) 20 21 func TestConfig(t *testing.T) { 22 params := configSetup(t) 23 configSetTest(t, params) 24 configPushTest(t, params) 25 configListTest(t, params, false) 26 appsOpenTest(t, params) 27 configUnsetTest(t, params) 28 configListTest(t, params, true) 29 limitsSetTest(t, params, 4) 30 appsOpenTest(t, params) 31 limitsUnsetTest(t, params, 6) 32 appsOpenTest(t, params) 33 //tagsTest(t, params, 8) 34 appsOpenTest(t, params) 35 utils.AppsDestroyTest(t, params) 36 } 37 38 func configSetup(t *testing.T) *utils.DeisTestConfig { 39 cfg := utils.GetGlobalConfig() 40 cfg.AppName = "configsample" 41 utils.Execute(t, authLoginCmd, cfg, false, "") 42 utils.Execute(t, gitCloneCmd, cfg, false, "") 43 if err := utils.Chdir(cfg.ExampleApp); err != nil { 44 t.Fatal(err) 45 } 46 utils.Execute(t, appsCreateCmd, cfg, false, "") 47 // ensure envvars with spaces work fine on `git push` 48 // https://github.com/deis/deis/issues/2477 49 utils.Execute(t, configSet3Cmd, cfg, false, "the Deis team") 50 // ensure custom buildpack URLS are in order 51 utils.Execute(t, configSetBuildpackCmd, cfg, false, "https://github.com/heroku/heroku-buildpack-go#98f37cc") 52 utils.Execute(t, gitPushCmd, cfg, false, "") 53 utils.CurlApp(t, *cfg) 54 utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_APP", false) 55 utils.CheckList(t, "run env --app={{.AppName}}", cfg, "DEIS_RELEASE", false) 56 if err := utils.Chdir(".."); err != nil { 57 t.Fatal(err) 58 } 59 return cfg 60 } 61 62 func configListTest( 63 t *testing.T, params *utils.DeisTestConfig, notflag bool) { 64 utils.CheckList(t, configListCmd, params, "FOO", notflag) 65 } 66 67 func configSetTest(t *testing.T, params *utils.DeisTestConfig) { 68 utils.Execute(t, configSetCmd, params, false, "讲台") 69 utils.CheckList(t, appsInfoCmd, params, "(v5)", false) 70 utils.Execute(t, configSet2Cmd, params, false, "10") 71 utils.CheckList(t, appsInfoCmd, params, "(v6)", false) 72 } 73 74 func configPushTest(t *testing.T, params *utils.DeisTestConfig) { 75 if err := utils.Chdir(params.ExampleApp); err != nil { 76 t.Fatal(err) 77 } 78 // create a .env in the project root 79 if err := ioutil.WriteFile(".env", []byte("POWERED_BY=Deis"), 0664); err != nil { 80 t.Fatal(err) 81 } 82 utils.Execute(t, "config:push --app {{.AppName}}", params, false, "Deis") 83 utils.CheckList(t, appsInfoCmd, params, "(v7)", false) 84 if err := utils.Chdir(".."); err != nil { 85 t.Fatal(err) 86 } 87 } 88 89 func configUnsetTest(t *testing.T, params *utils.DeisTestConfig) { 90 utils.Execute(t, configUnsetCmd, params, false, "") 91 utils.CheckList(t, appsInfoCmd, params, "(v8)", false) 92 utils.CheckList(t, "run env --app={{.AppName}}", params, "FOO", true) 93 }