Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ linters:
constant-kind: true

usetesting:
os-temp-dir: false
os-temp-dir: true
context-background: true
context-todo: true

Expand Down Expand Up @@ -623,16 +623,6 @@ linters:
path: pkg/(appsec|acquisition|dumps|alertcontext|leakybucket|exprhelpers)
text: 'rangeValCopy: .*'

- linters:
- usetesting
path: pkg/apiserver/(.+)_test.go
text: os.MkdirTemp.* could be replaced by t.TempDir.*

- linters:
- usetesting
path: pkg/apiserver/(.+)_test.go
text: os.CreateTemp.* could be replaced by os.CreateTemp.*

- linters:
- containedctx
path: cmd/notification-file/main.go
Expand Down
3 changes: 1 addition & 2 deletions pkg/acquisition/modules/appsec/appsec_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package appsecacquisition
import (
"net/http"
"net/url"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -384,7 +383,7 @@ toto
require.True(t, responses[0].InBandInterrupt)

// Might fail if you have artifacts from previous tests, but good enough 99% of the time
tmpFiles, err := filepath.Glob(filepath.Join(os.TempDir(), "crzmp*"))
tmpFiles, err := filepath.Glob(filepath.Join(t.TempDir(), "crzmp*"))
require.NoError(t, err)
require.Empty(t, tmpFiles)
},
Expand Down
12 changes: 2 additions & 10 deletions pkg/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ func LoadTestConfig(t *testing.T) csconfig.Config {
MaxAge: maxAge,
}

tempDir, _ := os.MkdirTemp("", "crowdsec_tests")

t.Cleanup(func() { os.RemoveAll(tempDir) })

dbconfig := csconfig.DatabaseCfg{
Type: "sqlite",
DbPath: filepath.Join(tempDir, "ent"),
DbPath: filepath.Join(t.TempDir(), "ent"),
Flush: &flushConfig,
}
apiServerConfig := csconfig.LocalApiServerCfg{
Expand Down Expand Up @@ -104,13 +100,9 @@ func LoadTestConfigForwardedFor(t *testing.T) csconfig.Config {
MaxAge: maxAge,
}

tempDir, _ := os.MkdirTemp("", "crowdsec_tests")

t.Cleanup(func() { os.RemoveAll(tempDir) })

dbconfig := csconfig.DatabaseCfg{
Type: "sqlite",
DbPath: filepath.Join(tempDir, "ent"),
DbPath: filepath.Join(t.TempDir(), "ent"),
Flush: &flushConfig,
}
apiServerConfig := csconfig.LocalApiServerCfg{
Expand Down
Loading