-
Notifications
You must be signed in to change notification settings - Fork 31
/
cli_test.go
60 lines (50 loc) · 1.59 KB
/
cli_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
package main
import (
"bytes"
"regexp"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type CLITestSuite struct {
suite.Suite
verifyStart func(*testing.T, *bool)
}
func TestCLI(t *testing.T) {
suite.Run(t, new(CLITestSuite))
}
func (s *CLITestSuite) Test_initCLI() {
cli := initCLI()
assert.NotNil(s.T(), cli.config)
assert.NotNil(s.T(), cli.logger)
assert.NotNil(s.T(), cli.instance)
assert.NotNil(s.T(), cli.instance.Name)
assert.NotNil(s.T(), cli.instance.Usage)
assert.NotNil(s.T(), cli.instance.Description)
}
func (s *CLITestSuite) TestStart_provisionsDefault() {
ensureCLIStartSetsRunFlag(s.T(), []string{"godev"}, "RunDefault")
}
func (s *CLITestSuite) TestStart_provisionsInit() {
ensureCLIStartSetsRunFlag(s.T(), []string{"godev", "init"}, "RunInit")
}
func (s *CLITestSuite) TestStart_provisionsTest() {
ensureCLIStartSetsRunFlag(s.T(), []string{"godev", "test"}, "RunTest")
}
func (s *CLITestSuite) TestStart_provisionsVersion() {
ensureCLIStartSetsRunFlag(s.T(), []string{"godev", "version"}, "RunVersion", func(logs bytes.Buffer) {
assert.Regexp(
s.T(),
regexp.MustCompile(`^godev [\d]*\.[\d]*\.[\d]*\-[a-f0-9]{7}`),
logs.String(),
)
})
}
func (s *CLITestSuite) TestStart_provisionsView() {
ensureCLIStartSetsRunFlag(s.T(), []string{"godev", "view", "dockerfile"}, "RunView", func(logs bytes.Buffer) {
assert.Contains(s.T(), logs.String(), DataDockerfile)
})
ensureCLIStartSetsRunFlag(s.T(), []string{"godev", "view", "makefile"}, "RunView", func(logs bytes.Buffer) {
assert.Contains(s.T(), logs.String(), DataMakefile)
})
}