-
Notifications
You must be signed in to change notification settings - Fork 31
/
cli_init_handler_test.go
52 lines (44 loc) · 1.12 KB
/
cli_init_handler_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/urfave/cli"
)
type CLIInitHandlerTestSuite struct {
suite.Suite
mockApp *cli.App
mockContext *cli.Context
}
func TestCLIInitHandler(t *testing.T) {
suite.Run(t, new(CLIInitHandlerTestSuite))
}
func (s *CLIInitHandlerTestSuite) SetupTest() {
s.mockApp = cli.NewApp()
s.mockApp.Flags = getInitFlags()
s.mockContext = cli.NewContext(s.mockApp, nil, nil)
}
func (s *CLIInitHandlerTestSuite) Test_getInitCommand() {
config := Config{}
command := getInitCommand(&config)
ensureCLICommand(s.T(), command, []string{"init", "i"}, getInitFlags())
}
func (s *CLIDefaultHandlerTestSuite) Test_getInitFlags() {
ensureCLIFlags(s.T(),
[]string{
"dir",
},
getInitFlags(),
)
}
func (s *CLIInitHandlerTestSuite) Test_getInitAction() {
t := s.T()
config := Config{}
s.mockApp.Action = getInitAction(&config)
if err := s.mockApp.Run([]string{"test-run-init"}); err == nil {
assert.True(t, config.RunInit)
assert.Equal(t, getCurrentWorkingDirectory(), config.WorkDirectory)
} else {
panic(err)
}
}