@@ -5,28 +5,29 @@ import (
55 . "github.com/onsi/gomega"
66 "github.com/onsi/gomega/gbytes"
77 "github.com/onsi/gomega/gexec"
8+ "time"
89)
910
1011var _ = Describe ("Apps" , func () {
11- app1Name := getRandAppName ()
12- app2Name := getRandAppName ()
13- Context ("with a logged-in user" , func () {
14- BeforeEach (func () {
15- login (url , testUser , testPassword )
16- })
12+ var appName string
13+
14+ BeforeEach (func () {
15+ appName = getRandAppName ()
16+ })
17+
18+ Context ("with no app" , func () {
1719
1820 It ("can't get app info" , func () {
19- sess , err := start ("deis info -a %s" , app1Name )
20- Expect (err ).ToNot (BeNil ())
21- Eventually (sess ).ShouldNot (gexec .Exit (0 ))
22- Eventually (sess ).Should (gbytes .Say ("NOT FOUND" ))
21+ sess , _ := start ("deis info -a %s" , appName )
22+ Eventually (sess ).Should (gexec .Exit (1 ))
23+ Eventually (sess .Err ).Should (gbytes .Say ("NOT FOUND" ))
2324 })
2425
2526 It ("can't get app logs" , func () {
26- sess , err := start ("deis logs -a %s" , app1Name )
27+ sess , err := start ("deis logs -a %s" , appName )
2728 Expect (err ).To (BeNil ())
2829 Eventually (sess ).ShouldNot (gexec .Exit (0 ))
29- Eventually (sess ).Should (gbytes .Say ("NOT FOUND" ))
30+ Eventually (sess . Err ).Should (gbytes .Say ("NOT FOUND" ))
3031 })
3132
3233 // TODO: this currently returns "Error: json: cannot unmarshal object into Go value of type []interface {}"
@@ -37,111 +38,103 @@ var _ = Describe("Apps", func() {
3738 Eventually (sess ).Should (gbytes .Say ("NOT FOUND" ))
3839 })
3940
40- It ("can create an app" , func () {
41- sess , err := start ("deis apps:create %s" , app1Name )
42- Expect (err ).To (BeNil ())
43- Eventually (sess ).Should (gexec .Exit (0 ))
44- Eventually (sess ).Should (gbytes .Say ("Creating Application... done, created %s" , app1Name ))
45- Eventually (sess ).Should (gbytes .Say ("Git remote deis added" ))
46- Eventually (sess ).Should (gbytes .Say ("remote available at " ))
41+ })
4742
48- sess , err = start ( "deis apps:destroy --confirm=%s " , app1Name )
49- Expect ( err ). To ( BeNil ())
50- Eventually ( sess ). Should ( gexec . Exit ( 0 ))
51- Eventually ( sess ). Should ( gbytes . Say ( "Destroying %s..." , app1Name ))
52- Eventually ( sess ). Should ( gbytes . Say ( "done in " ))
53- Eventually ( sess ). Should ( gbytes . Say ( "Git remote deis removed" ) )
43+ Context ( "when creating an app " , func () {
44+ var cleanup bool
45+
46+ BeforeEach ( func () {
47+ cleanup = true
48+ appName = getRandAppName ( )
5449 })
5550
56- It ("can create an app with no git remote" , func () {
57- sess , err := start ("deis apps:create %s --no-remote" , app1Name )
58- Expect (err ).To (BeNil ())
59- Eventually (sess ).Should (gexec .Exit (0 ))
60- Eventually (sess ).Should (gbytes .Say ("Creating Application... done, created %s" , app1Name ))
61- Eventually (sess ).Should (gbytes .Say ("remove available at " ))
62- Eventually (sess ).ShouldNot (gbytes .Say ("git remote deis added" ))
51+ AfterEach (func () {
52+ if cleanup {
53+ destroyApp (appName )
54+ }
55+ })
6356
64- sess , err = start ( "deis apps:destroy -- app=%s --confirm=%s " , app1Name , app1Name )
65- Expect ( err ). To ( BeNil () )
66- Eventually ( sess ). Should ( gexec . Exit ( 0 ))
67- Eventually (sess ).Should (gbytes .Say ("Destroying %s... " , app1Name ))
68- Eventually (sess ).Should (gbytes .Say ("done in " ))
69- Eventually (sess ). ShouldNot (gbytes .Say ("Git remote deis removed" ))
57+ It ( "creates an app with a git remote " , func () {
58+ cmd , err := start ( "deis apps:create %s" , appName )
59+ Expect ( err ). NotTo ( HaveOccurred ( ))
60+ Eventually (cmd ).Should (gbytes .Say ("created %s" , appName ))
61+ Eventually (cmd ).Should (gbytes .Say (`Git remote deis added` ))
62+ Eventually (cmd ). Should (gbytes .Say (` remote available at ` ))
7063 })
7164
72- It ("can create an app with a custom buildpack" , func () {
73- sess , err := start ("deis apps:create %s --buildpack https://example.com" , app1Name )
65+ It ("creates an app with no git remote" , func () {
66+ cmd , err := start ("deis apps:create %s --no-remote" , appName )
67+ Expect (err ).NotTo (HaveOccurred ())
68+ Eventually (cmd ).Should (SatisfyAll (
69+ gbytes .Say ("created %s" , appName ),
70+ gbytes .Say ("remote available at " )))
71+ Eventually (cmd ).ShouldNot (gbytes .Say ("Git remote deis added" ))
72+
73+ cleanup = false
74+ cmd = destroyApp (appName )
75+ Eventually (cmd ).ShouldNot (gbytes .Say ("Git remote deis removed" ))
76+ })
77+
78+ It ("creates an app with a custom buildpack" , func () {
79+ sess , err := start ("deis apps:create %s --buildpack https://example.com" , appName )
7480 Expect (err ).To (BeNil ())
7581 Eventually (sess ).Should (gexec .Exit (0 ))
76- Eventually (sess ).Should (gbytes .Say ("Creating Application... done, created %s" , app1Name ))
82+ Eventually (sess ).Should (gbytes .Say ("created %s" , appName ))
7783 Eventually (sess ).Should (gbytes .Say ("Git remote deis added" ))
7884 Eventually (sess ).Should (gbytes .Say ("remote available at " ))
7985
8086 sess , err = start ("deis config:list" )
8187 Expect (err ).To (BeNil ())
8288 Eventually (sess ).Should (gexec .Exit (0 ))
8389 Eventually (sess ).Should (gbytes .Say ("BUILDPACK_URL" ))
84-
85- sess , err = start ("deis apps:destroy --app=%s --confirm=%s" , app1Name , app1Name )
86- Expect (err ).To (BeNil ())
87- Eventually (sess ).Should (gexec .Exit (0 ))
88- Eventually (sess ).Should (gbytes .Say ("Destroying %s..." , app1Name ))
89- Eventually (sess ).Should (gbytes .Say ("done in " ))
90- Eventually (sess ).Should (gbytes .Say ("Git remote deis removed" ))
9190 })
9291 })
9392
9493 Context ("with a deployed app" , func () {
95- repository := "https://github.com/deis/example-go.git"
96- It ("can clone the example-go repository" , func () {
97- sess , err := start ("git clone %s" , repository )
98- Expect (err ).To (BeNil ())
99- Eventually (sess ).Should (gexec .Exit (0 ))
100- Eventually (sess ).Should (gbytes .Say ("Cloning into " ))
101- Eventually (sess ).Should (gbytes .Say ("done." ))
94+ var appName string
10295
103- sess , err = start ("cd example-go" )
104- Expect (err ).To (BeNil ())
105- Expect (sess ).To (gexec .Exit (0 ))
106-
107- sess , err = start ("deis apps:create %s" , app2Name )
108- Expect (err ).To (BeNil ())
109- Eventually (sess ).Should (gexec .Exit (0 ))
110- Eventually (sess ).Should (gbytes .Say ("Creating Application... done, created %s" , app2Name ))
111- Eventually (sess ).Should (gbytes .Say ("Git remote deis added" ))
112- Eventually (sess ).Should (gbytes .Say ("remote available at " ))
96+ BeforeEach (func () {
97+ appName = getRandAppName ()
98+ cmd := createApp (appName )
99+ Eventually (cmd ).Should (SatisfyAll (
100+ gbytes .Say ("Git remote deis added" ),
101+ gbytes .Say ("remote available at " )))
102+
103+ cmd , err := start ("GIT_SSH=%s git push deis master" , gitSSH )
104+ Expect (err ).NotTo (HaveOccurred ())
105+ Eventually (cmd .Err , "2m" ).Should (gbytes .Say ("done, %s:v2 deployed to Deis" , appName ))
106+ })
113107
114- sess , err = start ("git push deis master" )
115- Expect (err ).To (BeNil ())
116- Eventually (sess ).Should (gexec .Exit (0 ))
117- Eventually (sess ).Should (gbytes .Say ("-----> Launching..." ))
118- Eventually (sess ).Should (gbytes .Say ("done, %s:v2 deployed to Deis" , app2Name ))
108+ AfterEach (func () {
109+ destroyApp (appName )
119110 })
120111
121112 It ("can't create an existing app" , func () {
122- sess , err := start ("deis apps:create %s" , app1Name )
123- Expect (err ).ToNot ( BeNil () )
124- Eventually ( sess ). ShouldNot ( gexec . Exit ( 0 ))
125- Eventually ( sess ). Should ( gbytes . Say ("This field must be unique" ))
113+ output , err := execute ("deis apps:create %s" , appName )
114+ Expect (err ).To ( HaveOccurred (), output )
115+
116+ Expect ( output ). To ( ContainSubstring ("This field must be unique" ))
126117 })
127118
128119 It ("can get app info" , func () {
129120 sess , err := start ("deis info" )
130- Expect (err ).To (BeNil ())
131- Eventually (sess ).Should (gexec .Exit (0 ))
132- Eventually (sess ).Should (gbytes .Say ("=== %s Application" , app2Name ))
133- Eventually (sess ).Should (gbytes .Say ("=== %s Processes" , app2Name ))
134- Eventually (sess ).Should (gbytes .Say (".1 up (v" ))
135- Eventually (sess ).Should (gbytes .Say ("=== %s Domains" , app2Name ))
121+ Expect (err ).NotTo (HaveOccurred ())
122+
123+ Eventually (sess ).Should (gbytes .Say ("=== %s Processes" , appName ))
124+ Eventually (sess ).Should (SatisfyAny (
125+ gbytes .Say ("web.1 initialized" ),
126+ gbytes .Say ("web.1 up" )))
127+ Eventually (sess ).Should (gbytes .Say ("=== %s Domains" , appName ))
136128 })
137129
138- It ("can get app logs" , func () {
139- sess , err := start ("deis logs" )
140- Expect (err ).To (BeNil ())
141- Eventually (sess ).Should (gexec .Exit (0 ))
142- Eventually (sess ).Should (gbytes .Say ("%s[deis-controller]: %s created initial release" , app2Name , testUser ))
143- Eventually (sess ).Should (gbytes .Say ("%s[deis-controller]: %s deployed" , app2Name , testUser ))
144- Eventually (sess ).Should (gbytes .Say ("%s[deis-controller]: %s scaled containers" , app2Name , testUser ))
130+ // V broken
131+ XIt ("can get app logs" , func () {
132+ cmd , err := start ("deis logs" )
133+ Expect (err ).NotTo (HaveOccurred ())
134+ Eventually (cmd ).Should (SatisfyAll (
135+ gbytes .Say ("%s\\ [deis-controller\\ ]\\ : %s created initial release" , appName , testUser ),
136+ gbytes .Say ("%s\\ [deis-controller\\ ]\\ : %s deployed" , appName , testUser ),
137+ gbytes .Say ("%s\\ [deis-controller\\ ]\\ : %s scaled containers" , appName , testUser )))
145138 })
146139
147140 // TODO: how to test "deis open" which spawns a browser?
@@ -151,19 +144,20 @@ var _ = Describe("Apps", func() {
151144 Eventually (sess ).Should (gexec .Exit (0 ))
152145 })
153146
154- It ( "can't open a bogus app URL" , func () {
155- sess , err := start ( "deis open -a %s " , getRandAppName ())
156- Expect ( err ). ToNot ( BeNil ())
157- Eventually ( sess ). ShouldNot ( gexec . Exit ( 0 ))
158- Eventually (sess ).Should (gbytes .Say ("404 NOT FOUND" ))
147+ // TODO: be more useful
148+ XIt ( "can't open a bogus app URL " , func () {
149+ cmd , err := start ( "deis open -a %s" , getRandAppName ())
150+ Expect ( err ). To ( HaveOccurred ( ))
151+ Eventually (cmd ).Should (gbytes .Say ("404 NOT FOUND" ))
159152 })
160153
161- It ("can run a command in the app environment" , func () {
162- sess , err := start ("deis apps:run echo Hello, 世界" )
163- Expect (err ).To (BeNil ())
164- Eventually (sess ).Should (gexec .Exit (0 ))
165- Eventually (sess ).Should (gbytes .Say ("Running 'echo Hello, 世界'..." ))
166- Eventually (sess ).Should (gbytes .Say ("Hello, 世界\n " ))
154+ // V broken
155+ XIt ("can run a command in the app environment" , func () {
156+ cmd , err := start ("deis apps:run echo Hello, 世界" )
157+ Expect (err ).NotTo (HaveOccurred ())
158+ Eventually (cmd , (1 * time .Minute )).Should (SatisfyAll (
159+ HavePrefix ("Running 'echo Hello, 世界'..." ),
160+ HaveSuffix ("Hello, 世界\n " )))
167161 })
168162
169163 // TODO: this requires a second user account
0 commit comments