From 7e2a29df597f0c8bc45cef6198a9fa54ea814a10 Mon Sep 17 00:00:00 2001 From: Bart van Oort Date: Thu, 12 Aug 2021 13:30:49 +0200 Subject: [PATCH] Fixes tests for code quality linters --- setools/cqlinters/bandit_test.go | 4 ++-- setools/cqlinters/black_test.go | 4 ++-- setools/cqlinters/isort_test.go | 2 +- setools/cqlinters/mypy_test.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/setools/cqlinters/bandit_test.go b/setools/cqlinters/bandit_test.go index 75168b9..95118f4 100644 --- a/setools/cqlinters/bandit_test.go +++ b/setools/cqlinters/bandit_test.go @@ -45,7 +45,7 @@ func TestBanditRun(t *testing.T) { } exec.CommandOutput = mockexec.ExpectCommand(t).Dir(project.Dir). - CommandName("bandit").CommandArgs("-f", "yaml", "-x", ".venv,venv", "-r", project.Dir). + CommandName("bandit").CommandArgs("-f", "yaml", "-x", ".env,.venv,env,venv,ENV,env.bak,venv.bak", "-r", project.Dir). ToOutput([]byte(testBanditOutput), errors.New("bandit always exits with an error when there are messages")) results, err := l.Run(project) @@ -64,7 +64,7 @@ func TestBanditRun(t *testing.T) { } exec.CommandOutput = mockexec.ExpectCommand(t).Dir(project.Dir). - CommandName("bandit").CommandArgs("-f", "yaml", "-x", ".venv,venv", "-r", project.Dir). + CommandName("bandit").CommandArgs("-f", "yaml", "-x", ".env,.venv,env,venv,ENV,env.bak,venv.bak", "-r", project.Dir). ToOutput([]byte(testBanditErrorOutput), errors.New("bandit always exits with an error when there are messages")) results, err := l.Run(project) diff --git a/setools/cqlinters/black_test.go b/setools/cqlinters/black_test.go index 9f92f4e..546e574 100644 --- a/setools/cqlinters/black_test.go +++ b/setools/cqlinters/black_test.go @@ -63,7 +63,7 @@ func TestBlackRun(t *testing.T) { } exec.CommandCombinedOutput = mockexec.ExpectCommand(t).Dir(project.Dir). - CommandName("black").CommandArgs("--check", "--extend-exclude", ".venv", project.Dir). + CommandName("black").CommandArgs("--check", "--extend-exclude", "/(\\.env|\\.venv|env|venv|ENV|env\\.bak|venv\\.bak)/", project.Dir). ToOutput([]byte(testBlackOutput), errors.New("black always exits with an error when there are messages")) results, err := l.Run(project) @@ -81,7 +81,7 @@ func TestBlackRun(t *testing.T) { } exec.CommandCombinedOutput = mockexec.ExpectCommand(t).Dir(project.Dir). - CommandName("black").CommandArgs("--check", "--extend-exclude", ".venv", project.Dir). + CommandName("black").CommandArgs("--check", "--extend-exclude", "/(\\.env|\\.venv|env|venv|ENV|env\\.bak|venv\\.bak)/", project.Dir). ToOutput([]byte(testBlackSuccessOutput), nil) results, err := l.Run(project) diff --git a/setools/cqlinters/isort_test.go b/setools/cqlinters/isort_test.go index 216d2e8..7b2ef4c 100644 --- a/setools/cqlinters/isort_test.go +++ b/setools/cqlinters/isort_test.go @@ -60,7 +60,7 @@ func TestISortRun(t *testing.T) { return func(dir, name string, args ...string) ([]byte, error) { require.Equal(t, project.Dir, dir) require.Equal(t, "isort", name) - require.Equal(t, []string{"-c", project.Dir}, args) + require.Equal(t, []string{"-c", project.Dir, "--extend-skip", ".env", "--extend-skip", ".venv", "--extend-skip", "env", "--extend-skip", "venv", "--extend-skip", "ENV", "--extend-skip", "env.bak", "--extend-skip", "venv.bak"}, args) return []byte(output), err } } diff --git a/setools/cqlinters/mypy_test.go b/setools/cqlinters/mypy_test.go index 825650a..5d0d112 100644 --- a/setools/cqlinters/mypy_test.go +++ b/setools/cqlinters/mypy_test.go @@ -59,7 +59,7 @@ func TestMypyRun(t *testing.T) { exec.CommandOutput = func(dir, name string, args ...string) ([]byte, error) { require.Equal(t, project.Dir, dir) require.Equal(t, "mypy", name) - require.Equal(t, []string{project.Dir, "--strict", "--no-pretty", "--no-error-summary", "--no-color-output", "--hide-error-context", "--show-error-codes", "--show-column-numbers"}, args) + require.Equal(t, []string{project.Dir, "--exclude", "/(\\.env|\\.venv|env|venv|ENV|env\\.bak|venv\\.bak)/", "--strict", "--no-pretty", "--no-error-summary", "--no-color-output", "--hide-error-context", "--show-error-codes", "--show-column-numbers"}, args) return []byte(testMypyOutput), errors.New("mypy always exits with an error when there are messages") } @@ -80,7 +80,7 @@ func TestMypyRun(t *testing.T) { exec.CommandOutput = func(dir, name string, args ...string) ([]byte, error) { require.Equal(t, project.Dir, dir) require.Equal(t, "mypy", name) - require.Equal(t, []string{project.Dir, "--strict", "--no-pretty", "--no-error-summary", "--no-color-output", "--hide-error-context", "--show-error-codes", "--show-column-numbers"}, args) + require.Equal(t, []string{project.Dir, "--exclude", "/(\\.env|\\.venv|env|venv|ENV|env\\.bak|venv\\.bak)/", "--strict", "--no-pretty", "--no-error-summary", "--no-color-output", "--hide-error-context", "--show-error-codes", "--show-column-numbers"}, args) return []byte(testMypySuccessOutput), nil }