forked from heroku/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
58 lines (50 loc) · 1.02 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main_test
import (
cli "github.com/heroku/cli"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("version", func() {
exit := 9999
BeforeEach(func() {
cli.ExitFn = func(code int) {
if exit == 9999 {
exit = code
}
}
})
AfterEach(func() {
exit = 9999
})
Context("with no args", func() {
ran := false
var topicBackup cli.Topics
BeforeEach(func() {
topicBackup = cli.CLITopics
cli.CLITopics = cli.Topics{
{
Name: "dashboard",
Commands: cli.Commands{{Run: func(*cli.Context) { ran = true }}},
},
}
cli.Start("heroku")
})
AfterEach(func() {
cli.CLITopics = topicBackup
})
It("ran dashboard command", func() { Expect(ran).To(BeTrue()) })
})
Describe("ShowDebugInfo", func() {
BeforeEach(func() {
cli.Debugging = true
cli.Args = []string{"heroku", "test"}
cli.ShowDebugInfo()
})
AfterEach(func() {
cli.Debugging = false
})
It("shows command", func() {
Expect(stderr()).To(ContainSubstring("cmd: test"))
})
})
})