-
Notifications
You must be signed in to change notification settings - Fork 31
/
cli_view_handler_test.go
40 lines (33 loc) · 1.05 KB
/
cli_view_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/urfave/cli"
)
type CLIViewHandlerTestSuite struct {
suite.Suite
mockApp *cli.App
mockContext *cli.Context
}
func TestCLIViewHandler(t *testing.T) {
suite.Run(t, new(CLIViewHandlerTestSuite))
}
func (s *CLIViewHandlerTestSuite) SetupTest() {
s.mockApp = cli.NewApp()
s.mockContext = cli.NewContext(s.mockApp, nil, nil)
}
func (s *CLIViewHandlerTestSuite) Test_getViewCommand() {
config := Config{}
logger := InitLogger(&LoggerConfig{Name: "getViewCommand", Format: "raw", Level: "trace"})
command := getViewCommand(&config, logger)
ensureCLICommand(s.T(), command, []string{"view", "V"}, []cli.Flag(nil))
}
func (s *CLIViewHandlerTestSuite) Test_getViewAction() {
t := s.T()
config := Config{}
logger := InitLogger(&LoggerConfig{Name: "getViewAction", Format: "raw", Level: "trace"})
s.mockApp.Action = getViewAction(&config, logger)
_ = s.mockApp.Run([]string{"test-run-version", "dockerfile"})
assert.True(t, config.RunView)
}