11package _tests_test
22
33import (
4+ "fmt"
45 . "github.com/onsi/ginkgo"
56 . "github.com/onsi/gomega"
7+ "math/rand"
68)
79
10+ func getRandAppName () string {
11+ return fmt .Sprintf ("apps-test-%d" , rand .Int ())
12+ }
13+
814var _ = Describe ("Apps" , func () {
15+ app1Name := getRandAppName ()
16+ app2Name := getRandAppName ()
917 Context ("with a logged-in user" , func () {
10- appName := "apps-test"
11-
1218 BeforeEach (func () {
1319 login (url , testUser , testPassword )
1420 })
1521
1622 It ("can't get app info" , func () {
17- output , err := execute ("deis info -a %s" , appName )
23+ output , err := execute ("deis info -a %s" , app1Name )
1824 Expect (err ).To (HaveOccurred ())
1925 Expect (output ).To (ContainSubstring ("NOT FOUND" ))
2026 })
2127
2228 It ("can't get app logs" , func () {
23- output , err := execute ("deis logs -a %s" , appName )
29+ output , err := execute ("deis logs -a %s" , app1Name )
2430 Expect (err ).To (HaveOccurred ())
2531 Expect (output ).To (ContainSubstring ("NOT FOUND" ))
2632 })
@@ -33,128 +39,124 @@ var _ = Describe("Apps", func() {
3339 })
3440
3541 It ("can create an app" , func () {
36- output , err := execute ("deis apps:create %s" , appName )
42+ output , err := execute ("deis apps:create %s" , app1Name )
3743 Expect (err ).NotTo (HaveOccurred ())
3844 Expect (output ).To (SatisfyAll (
39- ContainSubstring ("Creating Application... done, created %s" , appName ),
45+ ContainSubstring ("Creating Application... done, created %s" , app1Name ),
4046 ContainSubstring ("Git remote deis added" ),
4147 ContainSubstring ("remote available at " )))
42- output , err = execute ("deis apps:destroy --confirm=%s" , appName )
48+ output , err = execute ("deis apps:destroy --confirm=%s" , app1Name )
4349 Expect (err ).NotTo (HaveOccurred ())
4450 Expect (output ).To (SatisfyAll (
45- ContainSubstring ("Destroying %s..." , appName ),
51+ ContainSubstring ("Destroying %s..." , app1Name ),
4652 ContainSubstring ("done in " ),
4753 ContainSubstring ("Git remote deis removed" )))
4854 })
4955
5056 It ("can create an app with no git remote" , func () {
51- output , err := execute ("deis apps:create %s --no-remote" , appName )
57+ output , err := execute ("deis apps:create %s --no-remote" , app1Name )
5258 Expect (err ).NotTo (HaveOccurred ())
5359 Expect (output ).To (SatisfyAll (
54- ContainSubstring ("Creating Application... done, created %s" , appName ),
60+ ContainSubstring ("Creating Application... done, created %s" , app1Name ),
5561 ContainSubstring ("remote available at " )))
5662 Expect (output ).NotTo (ContainSubstring ("Git remote deis added" ))
57- output , err = execute ("deis apps:destroy --app=%s --confirm=%s" , appName , appName )
63+ output , err = execute ("deis apps:destroy --app=%s --confirm=%s" , app1Name , app1Name )
5864 Expect (err ).NotTo (HaveOccurred ())
5965 Expect (output ).To (SatisfyAll (
60- ContainSubstring ("Destroying %s..." , appName ),
66+ ContainSubstring ("Destroying %s..." , app1Name ),
6167 ContainSubstring ("done in " )))
6268 Expect (output ).NotTo (ContainSubstring ("Git remote deis removed" ))
6369 })
6470
6571 It ("can create an app with a custom buildpack" , func () {
66- output , err := execute ("deis apps:create %s --buildpack https://example.com" , appName )
72+ output , err := execute ("deis apps:create %s --buildpack https://example.com" , app1Name )
6773 Expect (err ).NotTo (HaveOccurred ())
6874 Expect (output ).To (SatisfyAll (
69- ContainSubstring ("Creating Application... done, created %s" , appName ),
75+ ContainSubstring ("Creating Application... done, created %s" , app1Name ),
7076 ContainSubstring ("Git remote deis added" ),
7177 ContainSubstring ("remote available at " )))
7278 output , err = execute ("deis config:list" )
7379 Expect (err ).NotTo (HaveOccurred ())
7480 Expect (output ).To (ContainSubstring ("BUILDPACK_URL" ))
75- output , err = execute ("deis apps:destroy --app=%s --confirm=%s" , appName , appName )
81+ output , err = execute ("deis apps:destroy --app=%s --confirm=%s" , app1Name , app1Name )
7682 Expect (err ).NotTo (HaveOccurred ())
7783 Expect (output ).To (SatisfyAll (
78- ContainSubstring ("Destroying %s..." , appName ),
84+ ContainSubstring ("Destroying %s..." , app1Name ),
7985 ContainSubstring ("done in " ),
8086 ContainSubstring ("Git remote deis removed" )))
8187 })
8288 })
8389
84- // Context("with a deployed app", func() {
85- //
86- // appName := "apps-test"
87- // repository := "https://github.com/deis/example-go.git"
88- //
89- // TODO: can't have an Expect outside an It clause...need to refactor
90- // output, err := execute("git clone %s", repository)
91- // Expect(err).NotTo(HaveOccurred())
92- // Expect(output).To(SatisfyAll(
93- // ContainSubstring("Cloning into "),
94- // ContainSubstring("done.")))
95- // // TODO: change directory to cloned app dir
96- // output, err = execute("deis apps:create %s", appName)
97- // Expect(err).NotTo(HaveOccurred())
98- // Expect(output).To(SatisfyAll(
99- // ContainSubstring("Creating Application... done, created %s", appName),
100- // ContainSubstring("Git remote deis added"),
101- // ContainSubstring("remote available at ")))
102- // output, err = execute("git push deis master")
103- // Expect(err).NotTo(HaveOccurred())
104- // Expect(output).To(SatisfyAll(
105- // ContainSubstring("-----> Launching..."),
106- // ContainSubstring("done, %s:v2 deployed to Deis", appName)))
107- //
108- // It("can't create an existing app", func() {
109- // output, err = execute("deis apps:create %s", appName)
110- // Expect(err).To(HaveOccurred())
111- // Expect(output).To(ContainSubstring("This field must be unique"))
112- // })
113- //
114- // It("can get app info", func() {
115- // output, err := execute("deis info")
116- // Expect(err).NotTo(HaveOccurred())
117- // Expect(output).To(SatisfyAll(
118- // HavePrefix("=== %s Application", appName),
119- // ContainSubstring("=== %s Processes", appName),
120- // ContainSubstring(".1 up (v"),
121- // ContainSubstring("=== %s Domains", appName)))
122- // })
123- //
124- // It("can get app logs", func() {
125- // output, err := execute("deis logs")
126- // Expect(err).NotTo(HaveOccurred())
127- // Expect(output).To(SatisfyAll(
128- // ContainSubstring("%s[deis-controller]: %s created initial release",
129- // appName, username),
130- // ContainSubstring("%s[deis-controller]: %s deployed", appName, username),
131- // ContainSubstring("%s[deis-controller]: %s scaled containers",
132- // appName, username)))
133- // })
134- //
135- // // TODO: how to test "deis open" which spawns a browser?
136- // XIt("can open the app's URL", func() {
137- // _, err := execute("deis open")
138- // Expect(err).NotTo(HaveOccurred())
139- // })
140- //
141- // It("can't open a bogus app URL", func() {
142- // output, err := execute("deis open -a bogus-appname")
143- // Expect(err).To(HaveOccurred())
144- // Expect(output).To(ContainSubstring("404 NOT FOUND"))
145- // })
146- //
147- // It("can run a command in the app environment", func() {
148- // output, err := execute("deis apps:run echo Hello, 世界")
149- // Expect(err).NotTo(HaveOccurred())
150- // Expect(output).To(SatisfyAll(
151- // HavePrefix("Running 'echo Hello, 世界'..."),
152- // HaveSuffix("Hello, 世界\n")))
153- // })
154- //
155- // // TODO: this requires a second user account
156- // XIt("can transfer the app to another owner", func() {
157- // })
158- // })
90+ Context ("with a deployed app" , func () {
91+ repository := "https://github.com/deis/example-go.git"
92+ It ("can clone the example-go repository" , func () {
93+ output , err := execute ("git clone %s" , repository )
94+ Expect (err ).NotTo (HaveOccurred ())
95+ Expect (output ).To (SatisfyAll (
96+ ContainSubstring ("Cloning into " ),
97+ ContainSubstring ("done." )))
98+ _ , err = execute ("cd example-go" )
99+ Expect (err ).NotTo (HaveOccurred ())
100+ output , err = execute ("deis apps:create %s" , app2Name )
101+ Expect (err ).NotTo (HaveOccurred ())
102+ Expect (output ).To (SatisfyAll (
103+ ContainSubstring ("Creating Application... done, created %s" , app2Name ),
104+ ContainSubstring ("Git remote deis added" ),
105+ ContainSubstring ("remote available at " )))
106+ output , err = execute ("git push deis master" )
107+ Expect (err ).NotTo (HaveOccurred ())
108+ Expect (output ).To (SatisfyAll (
109+ ContainSubstring ("-----> Launching..." ),
110+ ContainSubstring ("done, %s:v2 deployed to Deis" , app2Name )))
111+ })
112+
113+ It ("can't create an existing app" , func () {
114+ output , err := execute ("deis apps:create %s" , app1Name )
115+ Expect (err ).To (HaveOccurred ())
116+ Expect (output ).To (ContainSubstring ("This field must be unique" ))
117+ })
118+
119+ It ("can get app info" , func () {
120+ output , err := execute ("deis info" )
121+ Expect (err ).NotTo (HaveOccurred ())
122+ Expect (output ).To (SatisfyAll (
123+ HavePrefix ("=== %s Application" , app2Name ),
124+ ContainSubstring ("=== %s Processes" , app2Name ),
125+ ContainSubstring (".1 up (v" ),
126+ ContainSubstring ("=== %s Domains" , app2Name )))
127+ })
128+
129+ It ("can get app logs" , func () {
130+ output , err := execute ("deis logs" )
131+ Expect (err ).NotTo (HaveOccurred ())
132+ Expect (output ).To (SatisfyAll (
133+ ContainSubstring ("%s[deis-controller]: %s created initial release" , app2Name , testUser ),
134+ ContainSubstring ("%s[deis-controller]: %s deployed" , app2Name , testUser ),
135+ ContainSubstring ("%s[deis-controller]: %s scaled containers" , app2Name , testUser )))
136+ })
137+
138+ // TODO: how to test "deis open" which spawns a browser?
139+ XIt ("can open the app's URL" , func () {
140+ _ , err := execute ("deis open" )
141+ Expect (err ).NotTo (HaveOccurred ())
142+ })
143+
144+ It ("can't open a bogus app URL" , func () {
145+ output , err := execute ("deis open -a %s" , getRandAppName ())
146+ Expect (err ).To (HaveOccurred ())
147+ Expect (output ).To (ContainSubstring ("404 NOT FOUND" ))
148+ })
159149
150+ It ("can run a command in the app environment" , func () {
151+ output , err := execute ("deis apps:run echo Hello, 世界" )
152+ Expect (err ).NotTo (HaveOccurred ())
153+ Expect (output ).To (SatisfyAll (
154+ HavePrefix ("Running 'echo Hello, 世界'..." ),
155+ HaveSuffix ("Hello, 世界\n " )))
156+ })
157+
158+ // TODO: this requires a second user account
159+ XIt ("can transfer the app to another owner" , func () {
160+ })
161+ })
160162})
0 commit comments