File tree Expand file tree Collapse file tree 4 files changed +5
-24
lines changed
acquisition/modules/appsec Expand file tree Collapse file tree 4 files changed +5
-24
lines changed Original file line number Diff line number Diff line change @@ -504,7 +504,7 @@ linters:
504504 constant-kind : true
505505
506506 usetesting :
507- os-temp-dir : false
507+ os-temp-dir : true
508508 context-background : true
509509 context-todo : true
510510
@@ -627,16 +627,6 @@ linters:
627627 path : pkg/(appsec|acquisition|dumps|alertcontext|leakybucket|exprhelpers)
628628 text : ' rangeValCopy: .*'
629629
630- - linters :
631- - usetesting
632- path : pkg/apiserver/(.+)_test.go
633- text : os.MkdirTemp.* could be replaced by t.TempDir.*
634-
635- - linters :
636- - usetesting
637- path : pkg/apiserver/(.+)_test.go
638- text : os.CreateTemp.* could be replaced by os.CreateTemp.*
639-
640630 - linters :
641631 - containedctx
642632 path : cmd/notification-file/main.go
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package appsecacquisition
33import (
44 "net/http"
55 "net/url"
6- "os"
76 "path/filepath"
87 "testing"
98
384383 require .True (t , responses [0 ].InBandInterrupt )
385384
386385 // Might fail if you have artifacts from previous tests, but good enough 99% of the time
387- tmpFiles , err := filepath .Glob (filepath .Join (os .TempDir (), "crzmp*" ))
386+ tmpFiles , err := filepath .Glob (filepath .Join (t .TempDir (), "crzmp*" ))
388387 require .NoError (t , err )
389388 require .Empty (t , tmpFiles )
390389 },
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ import (
3838func getDBClient (t * testing.T , ctx context.Context ) * database.Client {
3939 t .Helper ()
4040
41- dbPath , err := os .CreateTemp ("" , "*sqlite" )
41+ dbPath , err := os .CreateTemp (t . TempDir () , "*sqlite" )
4242 require .NoError (t , err )
4343 dbClient , err := database .NewClient (ctx , & csconfig.DatabaseCfg {
4444 Type : "sqlite" ,
Original file line number Diff line number Diff line change @@ -54,13 +54,9 @@ func LoadTestConfig(t *testing.T) csconfig.Config {
5454 MaxAge : maxAge ,
5555 }
5656
57- tempDir , _ := os .MkdirTemp ("" , "crowdsec_tests" )
58-
59- t .Cleanup (func () { os .RemoveAll (tempDir ) })
60-
6157 dbconfig := csconfig.DatabaseCfg {
6258 Type : "sqlite" ,
63- DbPath : filepath .Join (tempDir , "ent" ),
59+ DbPath : filepath .Join (t . TempDir () , "ent" ),
6460 Flush : & flushConfig ,
6561 }
6662 apiServerConfig := csconfig.LocalApiServerCfg {
@@ -104,13 +100,9 @@ func LoadTestConfigForwardedFor(t *testing.T) csconfig.Config {
104100 MaxAge : maxAge ,
105101 }
106102
107- tempDir , _ := os .MkdirTemp ("" , "crowdsec_tests" )
108-
109- t .Cleanup (func () { os .RemoveAll (tempDir ) })
110-
111103 dbconfig := csconfig.DatabaseCfg {
112104 Type : "sqlite" ,
113- DbPath : filepath .Join (tempDir , "ent" ),
105+ DbPath : filepath .Join (t . TempDir () , "ent" ),
114106 Flush : & flushConfig ,
115107 }
116108 apiServerConfig := csconfig.LocalApiServerCfg {
You can’t perform that action at this time.
0 commit comments