Skip to content

Commit 6213395

Browse files
committed
ref(apps_test.go): use gexec to execute commands in apps_test
1 parent 696ca26 commit 6213395

1 file changed

Lines changed: 40 additions & 33 deletions

File tree

_tests/apps_test.go

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -70,45 +70,52 @@ var _ = Describe("Apps", func() {
7070
})
7171

7272
It("can create an app with a custom buildpack", func() {
73-
output, err := execute("deis apps:create %s --buildpack https://example.com", app1Name)
74-
Expect(err).NotTo(HaveOccurred())
75-
Expect(output).To(SatisfyAll(
76-
ContainSubstring("Creating Application... done, created %s", app1Name),
77-
ContainSubstring("Git remote deis added"),
78-
ContainSubstring("remote available at ")))
79-
output, err = execute("deis config:list")
80-
Expect(err).NotTo(HaveOccurred())
81-
Expect(output).To(ContainSubstring("BUILDPACK_URL"))
82-
output, err = execute("deis apps:destroy --app=%s --confirm=%s", app1Name, app1Name)
83-
Expect(err).NotTo(HaveOccurred())
84-
Expect(output).To(SatisfyAll(
85-
ContainSubstring("Destroying %s...", app1Name),
86-
ContainSubstring("done in "),
87-
ContainSubstring("Git remote deis removed")))
73+
sess, err := start("deis apps:create %s --buildpack https://example.com", app1Name)
74+
Expect(err).To(BeNil())
75+
Eventually(sess).Should(gexec.Exit(0))
76+
Eventually(sess).Should(gbytes.Say("Creating Application... done, created %s", app1Name))
77+
Eventually(sess).Should(gbytes.Say("Git remote deis added"))
78+
Eventually(sess).Should(gbytes.Say("remote available at "))
79+
80+
sess, err = start("deis config:list")
81+
Expect(err).To(BeNil())
82+
Eventually(sess).Should(gexec.Exit(0))
83+
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"))
8891
})
8992
})
9093

9194
Context("with a deployed app", func() {
9295
repository := "https://github.com/deis/example-go.git"
9396
It("can clone the example-go repository", func() {
94-
output, err := execute("git clone %s", repository)
95-
Expect(err).NotTo(HaveOccurred())
96-
Expect(output).To(SatisfyAll(
97-
ContainSubstring("Cloning into "),
98-
ContainSubstring("done.")))
99-
_, err = execute("cd example-go")
100-
Expect(err).NotTo(HaveOccurred())
101-
output, err = execute("deis apps:create %s", app2Name)
102-
Expect(err).NotTo(HaveOccurred())
103-
Expect(output).To(SatisfyAll(
104-
ContainSubstring("Creating Application... done, created %s", app2Name),
105-
ContainSubstring("Git remote deis added"),
106-
ContainSubstring("remote available at ")))
107-
output, err = execute("git push deis master")
108-
Expect(err).NotTo(HaveOccurred())
109-
Expect(output).To(SatisfyAll(
110-
ContainSubstring("-----> Launching..."),
111-
ContainSubstring("done, %s:v2 deployed to Deis", app2Name)))
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."))
102+
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 "))
113+
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))
112119
})
113120

114121
It("can't create an existing app", func() {

0 commit comments

Comments
 (0)