Skip to content

Commit ada9a72

Browse files
committed
feat: simplify some test code
Signed-off-by: Brian McGee <[email protected]>
1 parent 96b1560 commit ada9a72

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/cli/format_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ func TestIncludesAndExcludes(t *testing.T) {
101101
as.Contains(string(out), fmt.Sprintf("%d files changed", 29))
102102

103103
// globally exclude nix files
104-
config.Global = struct{ Excludes []string }{
105-
Excludes: []string{"*.nix"},
106-
}
104+
config.Global.Excludes = []string{"*.nix"}
107105

108106
test.WriteConfig(t, configPath, config)
109107
out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)
@@ -118,32 +116,34 @@ func TestIncludesAndExcludes(t *testing.T) {
118116
as.NoError(err)
119117
as.Contains(string(out), fmt.Sprintf("%d files changed", 22))
120118

119+
echo := config.Formatters["echo"]
120+
121121
// remove python files from the echo formatter
122-
config.Formatters["echo"].Excludes = []string{"*.py"}
122+
echo.Excludes = []string{"*.py"}
123123

124124
test.WriteConfig(t, configPath, config)
125125
out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)
126126
as.NoError(err)
127127
as.Contains(string(out), fmt.Sprintf("%d files changed", 20))
128128

129129
// remove go files from the echo formatter
130-
config.Formatters["echo"].Excludes = []string{"*.py", "*.go"}
130+
echo.Excludes = []string{"*.py", "*.go"}
131131

132132
test.WriteConfig(t, configPath, config)
133133
out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)
134134
as.NoError(err)
135135
as.Contains(string(out), fmt.Sprintf("%d files changed", 19))
136136

137137
// adjust the includes for echo to only include elm files
138-
config.Formatters["echo"].Includes = []string{"*.elm"}
138+
echo.Includes = []string{"*.elm"}
139139

140140
test.WriteConfig(t, configPath, config)
141141
out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)
142142
as.NoError(err)
143143
as.Contains(string(out), fmt.Sprintf("%d files changed", 1))
144144

145145
// add js files to echo formatter
146-
config.Formatters["echo"].Includes = []string{"*.elm", "*.js"}
146+
echo.Includes = []string{"*.elm", "*.js"}
147147

148148
test.WriteConfig(t, configPath, config)
149149
out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)

0 commit comments

Comments
 (0)