diff --git a/.github/workflows/go-tests-windows.yml b/.github/workflows/go-tests-windows.yml index 3276dbb1bfd..44abbbe24a3 100644 --- a/.github/workflows/go-tests-windows.yml +++ b/.github/workflows/go-tests-windows.yml @@ -61,6 +61,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.62 + version: v1.63 args: --issues-exit-code=1 --timeout 10m only-new-issues: false diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 3a194e1084a..996394f879e 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -189,6 +189,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.62 + version: v1.63 args: --issues-exit-code=1 --timeout 10m only-new-issues: false diff --git a/pkg/apiserver/apic_test.go b/pkg/apiserver/apic_test.go index a8fbb40c4fa..c29029dab89 100644 --- a/pkg/apiserver/apic_test.go +++ b/pkg/apiserver/apic_test.go @@ -37,7 +37,7 @@ import ( func getDBClient(t *testing.T, ctx context.Context) *database.Client { t.Helper() - dbPath, err := os.CreateTemp("", "*sqlite") + dbPath, err := os.CreateTemp(t.TempDir(), "*sqlite") require.NoError(t, err) dbClient, err := database.NewClient(ctx, &csconfig.DatabaseCfg{ Type: "sqlite", diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index d8f24add75e..101208c8262 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -52,9 +52,7 @@ func LoadTestConfig(t *testing.T) csconfig.Config { MaxAge: &maxAge, } - tempDir, _ := os.MkdirTemp("", "crowdsec_tests") - - t.Cleanup(func() { os.RemoveAll(tempDir) }) + tempDir := t.TempDir() dbconfig := csconfig.DatabaseCfg{ Type: "sqlite", @@ -102,9 +100,7 @@ func LoadTestConfigForwardedFor(t *testing.T) csconfig.Config { MaxAge: &maxAge, } - tempDir, _ := os.MkdirTemp("", "crowdsec_tests") - - t.Cleanup(func() { os.RemoveAll(tempDir) }) + tempDir := t.TempDir() dbconfig := csconfig.DatabaseCfg{ Type: "sqlite", @@ -367,9 +363,7 @@ func TestLoggingDebugToFileConfig(t *testing.T) { MaxAge: &maxAge, } - tempDir, _ := os.MkdirTemp("", "crowdsec_tests") - - t.Cleanup(func() { os.RemoveAll(tempDir) }) + tempDir := t.TempDir() dbconfig := csconfig.DatabaseCfg{ Type: "sqlite", @@ -420,9 +414,7 @@ func TestLoggingErrorToFileConfig(t *testing.T) { MaxAge: &maxAge, } - tempDir, _ := os.MkdirTemp("", "crowdsec_tests") - - t.Cleanup(func() { os.RemoveAll(tempDir) }) + tempDir := t.TempDir() dbconfig := csconfig.DatabaseCfg{ Type: "sqlite", diff --git a/pkg/csplugin/listfiles_test.go b/pkg/csplugin/listfiles_test.go index c476d7a4e4a..4d2a7d78bb6 100644 --- a/pkg/csplugin/listfiles_test.go +++ b/pkg/csplugin/listfiles_test.go @@ -12,12 +12,8 @@ import ( ) func TestListFilesAtPath(t *testing.T) { - dir, err := os.MkdirTemp("", "test-listfiles") - require.NoError(t, err) - t.Cleanup(func() { - os.RemoveAll(dir) - }) - _, err = os.Create(filepath.Join(dir, "notification-gitter")) + dir := t.TempDir() + _, err := os.Create(filepath.Join(dir, "notification-gitter")) require.NoError(t, err) _, err = os.Create(filepath.Join(dir, "slack")) require.NoError(t, err) diff --git a/pkg/exprhelpers/exprlib_test.go b/pkg/exprhelpers/exprlib_test.go index f2eb208ebfa..5d7c14e8b09 100644 --- a/pkg/exprhelpers/exprlib_test.go +++ b/pkg/exprhelpers/exprlib_test.go @@ -26,7 +26,7 @@ const TestFolder = "tests" func getDBClient(t *testing.T) *database.Client { t.Helper() - dbPath, err := os.CreateTemp("", "*sqlite") + dbPath, err := os.CreateTemp(t.TempDir(), "*sqlite") require.NoError(t, err) ctx := context.Background() diff --git a/pkg/fflag/features_test.go b/pkg/fflag/features_test.go index 144e7049362..bf8ddeca8fd 100644 --- a/pkg/fflag/features_test.go +++ b/pkg/fflag/features_test.go @@ -351,11 +351,9 @@ func TestSetFromYaml(t *testing.T) { } func TestSetFromYamlFile(t *testing.T) { - tmpfile, err := os.CreateTemp("", "test") + tmpfile, err := os.CreateTemp(t.TempDir(), "test") require.NoError(t, err) - defer os.Remove(tmpfile.Name()) - // write the config file _, err = tmpfile.WriteString("- experimental1") require.NoError(t, err) diff --git a/pkg/setup/detect_test.go b/pkg/setup/detect_test.go index 475f3af0928..ecfe3e11e47 100644 --- a/pkg/setup/detect_test.go +++ b/pkg/setup/detect_test.go @@ -60,7 +60,7 @@ func TestSetupHelperProcess(t *testing.T) { func tempYAML(t *testing.T, content string) os.File { t.Helper() require := require.New(t) - file, err := os.CreateTemp("", "") + file, err := os.CreateTemp(t.TempDir(), "") require.NoError(err) _, err = file.WriteString(dedent.Dedent(content))