forked from deis/deis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps_test.go
105 lines (92 loc) · 2.83 KB
/
apps_test.go
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// +build integration
package tests
import (
"os"
"testing"
"github.com/deis/deis/tests/utils"
)
var (
appsCreateCmd = "apps:create {{.AppName}}"
appsCreateCmdNoRemote = "apps:create {{.AppName}} --no-remote"
appsListCmd = "apps:list"
appsRunCmd = "apps:run echo hello"
appsOpenCmd = "apps:open --app={{.AppName}}"
appsLogsCmd = "apps:logs --app={{.AppName}}"
appsInfoCmd = "apps:info --app={{.AppName}}"
appsDestroyCmd = "apps:destroy --app={{.AppName}} --confirm={{.AppName}}"
)
func TestApps(t *testing.T) {
params := appsSetup(t)
appsCreateTest(t, params)
appsListTest(t, params, false)
appsLogsTest(t, params)
appsInfoTest(t, params)
appsRunTest(t, params)
appsOpenTest(t, params)
appsDestroyTest(t, params)
appsListTest(t, params, true)
}
func appsSetup(t *testing.T) *utils.DeisTestConfig {
cfg := utils.GetGlobalConfig()
cfg.AppName = "appssample"
utils.Execute(t, authLoginCmd, cfg, false, "")
utils.Execute(t, gitCloneCmd, cfg, false, "")
return cfg
}
func appsCreateTest(t *testing.T, params *utils.DeisTestConfig) {
wd, _ := os.Getwd()
defer os.Chdir(wd)
if err := utils.Chdir(params.ExampleApp); err != nil {
t.Fatal(err)
}
cmd := appsCreateCmd
utils.Execute(t, cmd, params, false, "")
utils.Execute(t, cmd, params, true, "App with this Id already exists")
}
func appsDestroyTest(t *testing.T, params *utils.DeisTestConfig) {
if err := utils.Chdir(params.ExampleApp); err != nil {
t.Fatal(err)
}
utils.Execute(t, appsDestroyCmd, params, false, "")
if err := utils.Chdir(".."); err != nil {
t.Fatal(err)
}
if err := utils.Rmdir(params.ExampleApp); err != nil {
t.Fatal(err)
}
}
func appsInfoTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Execute(t, appsInfoCmd, params, false, "")
}
func appsListTest(t *testing.T, params *utils.DeisTestConfig, notflag bool) {
utils.CheckList(t, appsListCmd, params, params.AppName, notflag)
}
func appsLogsTest(t *testing.T, params *utils.DeisTestConfig) {
cmd := appsLogsCmd
// test for application lifecycle logs
utils.Execute(t, cmd, params, false, "204 NO CONTENT")
if err := utils.Chdir(params.ExampleApp); err != nil {
t.Fatal(err)
}
utils.Execute(t, gitPushCmd, params, false, "")
utils.Curl(t, params)
utils.Execute(t, cmd, params, false, "created initial release")
utils.Execute(t, cmd, params, false, "listening on 5000...")
if err := utils.Chdir(".."); err != nil {
t.Fatal(err)
}
}
func appsOpenTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Curl(t, params)
}
func appsRunTest(t *testing.T, params *utils.DeisTestConfig) {
cmd := appsRunCmd
if err := utils.Chdir(params.ExampleApp); err != nil {
t.Fatal(err)
}
utils.Execute(t, cmd, params, false, "hello")
if err := utils.Chdir(".."); err != nil {
t.Fatal(err)
}
utils.Execute(t, cmd, params, true, "Not found")
}