Skip to content

Commit 2ce1213

Browse files
committed
fix(apps_test.go,auth_test.go): use gexec
1 parent cef38a2 commit 2ce1213

2 files changed

Lines changed: 55 additions & 40 deletions

File tree

_tests/apps_test.go

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package _tests_test
33
import (
44
. "github.com/onsi/ginkgo"
55
. "github.com/onsi/gomega"
6+
"github.com/onsi/gomega/gbytes"
7+
"github.com/onsi/gomega/gexec"
68
)
79

810
var _ = Describe("Apps", func() {
@@ -14,49 +16,57 @@ var _ = Describe("Apps", func() {
1416
})
1517

1618
It("can't get app info", func() {
17-
Expect(execute("deis info -a %s", app1Name)).To(BeASuccessfulCmdWithOutput(ContainSubstring("NOT FOUND")))
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"))
1823
})
1924

2025
It("can't get app logs", func() {
21-
out, err := execute("deis logs -a %s", app1Name)
22-
Expect(err).To(HaveOccurred())
23-
Expect(out).To(ContainSubstring("NOT FOUND"))
26+
sess, err := start("deis logs -a %s", app1Name)
27+
Expect(err).To(BeNil())
28+
Eventually(sess).ShouldNot(gexec.Exit(0))
29+
Eventually(sess).Should(gbytes.Say("NOT FOUND"))
2430
})
2531

2632
// TODO: this currently returns "Error: json: cannot unmarshal object into Go value of type []interface {}"
2733
XIt("can't run a command in the app environment", func() {
28-
out, err := execute("deis apps:run echo Hello, 世界")
29-
Expect(err).To(HaveOccurred())
30-
Expect(out).To(ContainSubstring("NOT FOUND"))
34+
sess, err := start("deis apps:run echo Hello, 世界")
35+
Expect(err).To(BeNil())
36+
Eventually(sess).ShouldNot(gexec.Exit(0))
37+
Eventually(sess).Should(gbytes.Say("NOT FOUND"))
3138
})
3239

3340
It("can create an app", func() {
34-
Expect(execute("deis apps:create %s", app1Name)).To(BeASuccessfulCmdWithOutput(
35-
ContainSubstring("Creating Application... done, created %s", app1Name),
36-
ContainSubstring("Git remote deis added"),
37-
ContainSubstring("remote available at "),
38-
))
39-
40-
Expect(execute("deis apps:destroy --confirm=%s", app1Name)).To(BeASuccessfulCmdWithOutput(
41-
ContainSubstring("Destroying %s...", app1Name),
42-
ContainSubstring("done in "),
43-
ContainSubstring("Git remote deis removed"),
44-
))
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 "))
47+
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"))
4554
})
4655

4756
It("can create an app with no git remote", func() {
48-
output, err := execute("deis apps:create %s --no-remote", app1Name)
49-
Expect(err).NotTo(HaveOccurred())
50-
Expect(output).To(SatisfyAll(
51-
ContainSubstring("Creating Application... done, created %s", app1Name),
52-
ContainSubstring("remote available at ")))
53-
Expect(output).NotTo(ContainSubstring("Git remote deis added"))
54-
output, err = execute("deis apps:destroy --app=%s --confirm=%s", app1Name, app1Name)
55-
Expect(err).NotTo(HaveOccurred())
56-
Expect(output).To(SatisfyAll(
57-
ContainSubstring("Destroying %s...", app1Name),
58-
ContainSubstring("done in ")))
59-
Expect(output).NotTo(ContainSubstring("Git remote deis removed"))
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"))
63+
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"))
6070
})
6171

6272
It("can create an app with a custom buildpack", func() {

_tests/auth_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package _tests_test
33
import (
44
. "github.com/onsi/ginkgo"
55
. "github.com/onsi/gomega"
6+
"github.com/onsi/gomega/gbytes"
7+
"github.com/onsi/gomega/gexec"
68
)
79

810
var _ = Describe("Auth", func() {
@@ -12,10 +14,11 @@ var _ = Describe("Auth", func() {
1214
})
1315

1416
It("won't print the current user", func() {
15-
Expect(execute("deis auth:whoami")).To(BeASuccessfulCmdWithOutput(
16-
ContainSubstring("Not logged in."),
17-
ContainSubstring(testUser),
18-
))
17+
sess, err := start("deis auth:whoami")
18+
Expect(err).To(BeNil())
19+
Eventually(sess).Should(gexec.Exit(0))
20+
Eventually(sess).Should(gbytes.Say("Not logged in"))
21+
Eventually(sess).Should(gbytes.Say(testUser))
1922
})
2023
})
2124

@@ -36,15 +39,17 @@ var _ = Describe("Auth", func() {
3639
})
3740

3841
It("prints the current user", func() {
39-
Expect(execute("deis auth:whoami")).To(BeASuccessfulCmdWithOutput(
40-
ContainSubstring("You are %s", testUser),
41-
))
42+
sess, err := start("deis auth:whoami")
43+
Expect(err).To(BeNil())
44+
Eventually(sess).Should(gexec.Exit(0))
45+
Eventually(sess).Should(gbytes.Say("You are %s", testUser))
4246
})
4347

4448
It("regenerates the token for the current user", func() {
45-
Expect(execute("deis auth:regenerate")).To(BeASuccessfulCmdWithOutput(
46-
ContainSubstring("Token Regenerated"),
47-
))
49+
sess, err := start("deis auth:regenerate")
50+
Expect(err).To(BeNil())
51+
Eventually(sess).Should(gexec.Exit(0))
52+
Eventually(sess).Should(gbytes.Say("Token Regenerated"))
4853
})
4954
})
5055

0 commit comments

Comments
 (0)