(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestConfigRuntimeArgs(t *testing.T) { |
| 69 | // table driven tests |
| 70 | type testCase struct { |
| 71 | name string |
| 72 | args []string |
| 73 | key string |
| 74 | check func(t *testing.T, conf *Config) |
| 75 | } |
| 76 | testCases := []testCase{ |
| 77 | { |
| 78 | name: "test1", |
| 79 | args: []string{"--build.cmd", "go build -o ./tmp/main ."}, |
| 80 | key: "build.cmd", |
| 81 | check: func(t *testing.T, conf *Config) { |
| 82 | assert.Equal(t, "go build -o ./tmp/main .", conf.Build.Cmd) |
| 83 | }, |
| 84 | }, |
| 85 | { |
| 86 | name: "tmp dir test", |
| 87 | args: []string{"--tmp_dir", "test"}, |
| 88 | key: "tmp_dir", |
| 89 | check: func(t *testing.T, conf *Config) { |
| 90 | assert.Equal(t, "test", conf.TmpDir) |
| 91 | }, |
| 92 | }, |
| 93 | { |
| 94 | name: "check int64", |
| 95 | args: []string{"--build.kill_delay", "1000"}, |
| 96 | key: "build.kill_delay", |
| 97 | check: func(t *testing.T, conf *Config) { |
| 98 | assert.Equal(t, time.Duration(1000), conf.Build.KillDelay) |
| 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | name: "check bool", |
| 103 | args: []string{"--build.exclude_unchanged", "true"}, |
| 104 | key: "build.exclude_unchanged", |
| 105 | check: func(t *testing.T, conf *Config) { |
| 106 | assert.True(t, conf.Build.ExcludeUnchanged) |
| 107 | }, |
| 108 | }, |
| 109 | { |
| 110 | name: "check exclude_regex", |
| 111 | args: []string{"--build.exclude_regex", "_test.go,.html"}, |
| 112 | check: func(t *testing.T, conf *Config) { |
| 113 | assert.Equal(t, []string{"_test.go", ".html"}, conf.Build.ExcludeRegex) |
| 114 | }, |
| 115 | }, |
| 116 | { |
| 117 | name: "check exclude_regex with empty string", |
| 118 | args: []string{"--build.exclude_regex", ""}, |
| 119 | check: func(t *testing.T, conf *Config) { |
| 120 | assert.Equal(t, []string{}, conf.Build.ExcludeRegex) |
| 121 | t.Logf("%+v", conf.Build.ExcludeDir) |
| 122 | assert.NotEqual(t, []string{}, conf.Build.ExcludeDir) |
| 123 | }, |
| 124 | }, |
| 125 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…