Skip to content

Commit cba19c0

Browse files
committed
ref(apps_test.go): further convert to use gexec based command execution
1 parent 6213395 commit cba19c0

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

_tests/apps_test.go

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,48 +119,51 @@ var _ = Describe("Apps", func() {
119119
})
120120

121121
It("can't create an existing app", func() {
122-
output, err := execute("deis apps:create %s", app1Name)
123-
Expect(err).To(HaveOccurred())
124-
Expect(output).To(ContainSubstring("This field must be unique"))
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"))
125126
})
126127

127128
It("can get app info", func() {
128-
output, err := execute("deis info")
129-
Expect(err).NotTo(HaveOccurred())
130-
Expect(output).To(SatisfyAll(
131-
HavePrefix("=== %s Application", app2Name),
132-
ContainSubstring("=== %s Processes", app2Name),
133-
ContainSubstring(".1 up (v"),
134-
ContainSubstring("=== %s Domains", app2Name)))
129+
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))
135136
})
136137

137138
It("can get app logs", func() {
138-
output, err := execute("deis logs")
139-
Expect(err).NotTo(HaveOccurred())
140-
Expect(output).To(SatisfyAll(
141-
ContainSubstring("%s[deis-controller]: %s created initial release", app2Name, testUser),
142-
ContainSubstring("%s[deis-controller]: %s deployed", app2Name, testUser),
143-
ContainSubstring("%s[deis-controller]: %s scaled containers", app2Name, testUser)))
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))
144145
})
145146

146147
// TODO: how to test "deis open" which spawns a browser?
147148
XIt("can open the app's URL", func() {
148-
_, err := execute("deis open")
149-
Expect(err).NotTo(HaveOccurred())
149+
sess, err := start("deis open")
150+
Expect(err).To(BeNil())
151+
Eventually(sess).Should(gexec.Exit(0))
150152
})
151153

152154
It("can't open a bogus app URL", func() {
153-
output, err := execute("deis open -a %s", getRandAppName())
154-
Expect(err).To(HaveOccurred())
155-
Expect(output).To(ContainSubstring("404 NOT FOUND"))
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"))
156159
})
157160

158161
It("can run a command in the app environment", func() {
159-
output, err := execute("deis apps:run echo Hello, 世界")
160-
Expect(err).NotTo(HaveOccurred())
161-
Expect(output).To(SatisfyAll(
162-
HavePrefix("Running 'echo Hello, 世界'..."),
163-
HaveSuffix("Hello, 世界\n")))
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"))
164167
})
165168

166169
// TODO: this requires a second user account

0 commit comments

Comments
 (0)