From ada9a72a7e56ffea11af5899cb711b6bb66a7293 Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Tue, 2 Jan 2024 14:57:21 +0000 Subject: [PATCH] feat: simplify some test code Signed-off-by: Brian McGee --- internal/cli/format_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/cli/format_test.go b/internal/cli/format_test.go index 3aa319a..2521a93 100644 --- a/internal/cli/format_test.go +++ b/internal/cli/format_test.go @@ -101,9 +101,7 @@ func TestIncludesAndExcludes(t *testing.T) { as.Contains(string(out), fmt.Sprintf("%d files changed", 29)) // globally exclude nix files - config.Global = struct{ Excludes []string }{ - Excludes: []string{"*.nix"}, - } + config.Global.Excludes = []string{"*.nix"} test.WriteConfig(t, configPath, config) out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir) @@ -118,8 +116,10 @@ func TestIncludesAndExcludes(t *testing.T) { as.NoError(err) as.Contains(string(out), fmt.Sprintf("%d files changed", 22)) + echo := config.Formatters["echo"] + // remove python files from the echo formatter - config.Formatters["echo"].Excludes = []string{"*.py"} + echo.Excludes = []string{"*.py"} test.WriteConfig(t, configPath, config) out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir) @@ -127,7 +127,7 @@ func TestIncludesAndExcludes(t *testing.T) { as.Contains(string(out), fmt.Sprintf("%d files changed", 20)) // remove go files from the echo formatter - config.Formatters["echo"].Excludes = []string{"*.py", "*.go"} + echo.Excludes = []string{"*.py", "*.go"} test.WriteConfig(t, configPath, config) out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir) @@ -135,7 +135,7 @@ func TestIncludesAndExcludes(t *testing.T) { as.Contains(string(out), fmt.Sprintf("%d files changed", 19)) // adjust the includes for echo to only include elm files - config.Formatters["echo"].Includes = []string{"*.elm"} + echo.Includes = []string{"*.elm"} test.WriteConfig(t, configPath, config) out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir) @@ -143,7 +143,7 @@ func TestIncludesAndExcludes(t *testing.T) { as.Contains(string(out), fmt.Sprintf("%d files changed", 1)) // add js files to echo formatter - config.Formatters["echo"].Includes = []string{"*.elm", "*.js"} + echo.Includes = []string{"*.elm", "*.js"} test.WriteConfig(t, configPath, config) out, err = cmd(t, "-c", "--config-file", configPath, "--tree-root", tempDir)