-
Notifications
You must be signed in to change notification settings - Fork 31
/
config_test.go
62 lines (55 loc) · 1.88 KB
/
config_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type ConfigTestSuite struct {
suite.Suite
}
func TestConfigTestSuite(t *testing.T) {
suite.Run(t, new(ConfigTestSuite))
}
func (s *ConfigTestSuite) Test_assignDefaultsRun() {
t := s.T()
c := &Config{
BuildOutput: "bin/app",
WatchDirectory: "/some/path/to/watch",
WorkDirectory: "/some/path/to/work",
}
c.assignDefaults()
assert.Equal(t, "info", c.LogLevel.String())
assert.Equal(t, "/some/path/to/work/bin/app", c.BuildOutput)
assert.Equal(t, false, c.RunView)
assert.Equal(t, []string{"bin", "vendor"}, []string(c.IgnoredNames))
assert.Equal(t, []string{"go", "Makefile"}, []string(c.FileExtensions))
assert.Equal(t, "go mod vendor", c.ExecGroups[0])
assert.Equal(t, "go build -o /some/path/to/work/bin/app", c.ExecGroups[1])
assert.Equal(t, "/some/path/to/work/bin/app", c.ExecGroups[2])
}
func (s *ConfigTestSuite) Test_assignDefaultsTest() {
t := s.T()
c := &Config{
BuildOutput: "bin/app",
WatchDirectory: "/some/path/to/watch",
WorkDirectory: "/some/path/to/work",
RunTest: true,
}
c.assignDefaults()
assert.Equal(t, "info", c.LogLevel.String())
assert.Equal(t, "/some/path/to/work/bin/app", c.BuildOutput)
assert.Equal(t, false, c.RunView)
assert.Equal(t, []string{"bin", "vendor"}, []string(c.IgnoredNames))
assert.Equal(t, []string{"go", "Makefile"}, []string(c.FileExtensions))
assert.Equal(t, "go mod vendor", c.ExecGroups[0])
assert.Equal(t, "go build -o /some/path/to/work/bin/app", c.ExecGroups[1])
assert.Equal(t, "go test ./... -coverprofile c.out", c.ExecGroups[2])
}
func (s *ConfigTestSuite) Test_interpretLogLevel() {
c := &Config{LogVerbose: true}
c.interpretLogLevel()
assert.Equal(s.T(), "debug", c.LogLevel.String())
c = &Config{LogSuperVerbose: true}
c.interpretLogLevel()
assert.Equal(s.T(), "trace", c.LogLevel.String())
}