forked from heroku/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp_test.go
113 lines (94 loc) · 2.85 KB
/
help_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package main_test
import (
cli "github.com/heroku/cli"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Help", func() {
exit := 9999
BeforeEach(func() {
cli.ExitFn = func(code int) {
if exit == 9999 {
exit = code
}
}
})
AfterEach(func() {
exit = 9999
})
Context("heroku help", func() {
BeforeEach(func() {
cli.Start("heroku", "help")
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows the help", func() {
Expect(stdout()).To(HavePrefix("Usage: heroku COMMAND [--app APP] [command-specific-options]"))
})
})
Context("heroku hlp", func() {
BeforeEach(func() {
cli.Start("heroku", "hlp")
})
It("exits with code 2", func() { Expect(exit).To(Equal(2)) })
It("has no stdout", func() { Expect(stdout()).To(Equal("")) })
It("shows invalid command message", func() {
Expect(stderr()).To(Equal(` ! hlp is not a heroku command.
! Perhaps you meant help?
! Run heroku _ to run heroku help.
! Run heroku help for a list of available commands.
`))
})
It("reruns heroku help", func() {
cli.Start("heroku", "_")
Expect(stdout()).To(HavePrefix("Usage: heroku COMMAND [--app APP] [command-specific-options]"))
})
})
Context("heroku help plugins", func() {
BeforeEach(func() {
cli.Start("heroku", "help", "plugins")
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows help for plugins command", func() {
Expect(stdout()).To(HavePrefix("Usage: heroku plugins"))
Expect(stdout()).To(ContainSubstring("heroku plugins:link"))
})
})
Context("heroku plugins --help", func() {
BeforeEach(func() {
cli.Start("heroku", "plugins", "--help")
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows help for plugins command", func() {
Expect(stdout()).To(HavePrefix("Usage: heroku plugins"))
Expect(stdout()).To(ContainSubstring("heroku plugins:link"))
})
})
Context("heroku help plugins:foo", func() {
BeforeEach(func() {
cli.Start("heroku", "help", "plugins:foo")
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows help for plugins commands", func() {
Expect(stdout()).To(HavePrefix("Usage: heroku plugins:COMMAND"))
Expect(stdout()).To(ContainSubstring("heroku plugins:link"))
})
})
Context("heroku help plugins", func() {
BeforeEach(func() {
cli.Start("heroku", "help", "plugins")
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows help for plugins commands", func() {
Expect(stdout()).To(ContainSubstring("heroku plugins:link"))
})
})
Context("help command", func() {
BeforeEach(func() {
cli.AllCommands().Find("help").Run(&cli.Context{})
})
It("exits with code 0", func() { Expect(exit).To(Equal(0)) })
It("shows help", func() {
Expect(stdout()).To(HavePrefix("Usage: heroku COMMAND"))
})
})
})