-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapps_test.go
More file actions
173 lines (150 loc) · 6.49 KB
/
apps_test.go
File metadata and controls
173 lines (150 loc) · 6.49 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package _tests_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Apps", func() {
app1Name := getRandAppName()
app2Name := getRandAppName()
Context("with a logged-in user", func() {
BeforeEach(func() {
login(url, testUser, testPassword)
})
It("can't get app info", func() {
sess, err := start("deis info -a %s", app1Name)
Expect(err).ToNot(BeNil())
Eventually(sess).ShouldNot(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("NOT FOUND"))
})
It("can't get app logs", func() {
sess, err := start("deis logs -a %s", app1Name)
Expect(err).To(BeNil())
Eventually(sess).ShouldNot(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("NOT FOUND"))
})
// TODO: this currently returns "Error: json: cannot unmarshal object into Go value of type []interface {}"
XIt("can't run a command in the app environment", func() {
sess, err := start("deis apps:run echo Hello, 世界")
Expect(err).To(BeNil())
Eventually(sess).ShouldNot(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("NOT FOUND"))
})
It("can create an app", func() {
sess, err := start("deis apps:create %s", app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Creating Application... done, created %s", app1Name))
Eventually(sess).Should(gbytes.Say("Git remote deis added"))
Eventually(sess).Should(gbytes.Say("remote available at "))
sess, err = start("deis apps:destroy --confirm=%s", app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Destroying %s...", app1Name))
Eventually(sess).Should(gbytes.Say("done in "))
Eventually(sess).Should(gbytes.Say("Git remote deis removed"))
})
It("can create an app with no git remote", func() {
sess, err := start("deis apps:create %s --no-remote", app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Creating Application... done, created %s", app1Name))
Eventually(sess).Should(gbytes.Say("remove available at "))
Eventually(sess).ShouldNot(gbytes.Say("git remote deis added"))
sess, err = start("deis apps:destroy --app=%s --confirm=%s", app1Name, app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Destroying %s...", app1Name))
Eventually(sess).Should(gbytes.Say("done in "))
Eventually(sess).ShouldNot(gbytes.Say("Git remote deis removed"))
})
It("can create an app with a custom buildpack", func() {
sess, err := start("deis apps:create %s --buildpack https://example.com", app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Creating Application... done, created %s", app1Name))
Eventually(sess).Should(gbytes.Say("Git remote deis added"))
Eventually(sess).Should(gbytes.Say("remote available at "))
sess, err = start("deis config:list")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("BUILDPACK_URL"))
sess, err = start("deis apps:destroy --app=%s --confirm=%s", app1Name, app1Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Destroying %s...", app1Name))
Eventually(sess).Should(gbytes.Say("done in "))
Eventually(sess).Should(gbytes.Say("Git remote deis removed"))
})
})
Context("with a deployed app", func() {
repository := "https://github.com/deis/example-go.git"
It("can clone the example-go repository", func() {
sess, err := start("git clone %s", repository)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Cloning into "))
Eventually(sess).Should(gbytes.Say("done."))
sess, err = start("cd example-go")
Expect(err).To(BeNil())
Expect(sess).To(gexec.Exit(0))
sess, err = start("deis apps:create %s", app2Name)
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Creating Application... done, created %s", app2Name))
Eventually(sess).Should(gbytes.Say("Git remote deis added"))
Eventually(sess).Should(gbytes.Say("remote available at "))
sess, err = start("git push deis master")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("-----> Launching..."))
Eventually(sess).Should(gbytes.Say("done, %s:v2 deployed to Deis", app2Name))
})
It("can't create an existing app", func() {
sess, err := start("deis apps:create %s", app1Name)
Expect(err).ToNot(BeNil())
Eventually(sess).ShouldNot(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("This field must be unique"))
})
It("can get app info", func() {
sess, err := start("deis info")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("=== %s Application", app2Name))
Eventually(sess).Should(gbytes.Say("=== %s Processes", app2Name))
Eventually(sess).Should(gbytes.Say(".1 up (v"))
Eventually(sess).Should(gbytes.Say("=== %s Domains", app2Name))
})
It("can get app logs", func() {
sess, err := start("deis logs")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("%s[deis-controller]: %s created initial release", app2Name, testUser))
Eventually(sess).Should(gbytes.Say("%s[deis-controller]: %s deployed", app2Name, testUser))
Eventually(sess).Should(gbytes.Say("%s[deis-controller]: %s scaled containers", app2Name, testUser))
})
// TODO: how to test "deis open" which spawns a browser?
XIt("can open the app's URL", func() {
sess, err := start("deis open")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
})
It("can't open a bogus app URL", func() {
sess, err := start("deis open -a %s", getRandAppName())
Expect(err).ToNot(BeNil())
Eventually(sess).ShouldNot(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("404 NOT FOUND"))
})
It("can run a command in the app environment", func() {
sess, err := start("deis apps:run echo Hello, 世界")
Expect(err).To(BeNil())
Eventually(sess).Should(gexec.Exit(0))
Eventually(sess).Should(gbytes.Say("Running 'echo Hello, 世界'..."))
Eventually(sess).Should(gbytes.Say("Hello, 世界\n"))
})
// TODO: this requires a second user account
XIt("can transfer the app to another owner", func() {
})
})
})