Skip to content

Commit

Permalink
test cleanup improvements (#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 authored Jan 28, 2025
1 parent 98c5e92 commit 293162a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/osquery/runsimple/osqueryrunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ func TestMain(m *testing.M) {
fmt.Println("Failed to make temp dir for test binaries")
os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests
}
defer os.RemoveAll(dir)

if err := downloadOsqueryInBinDir(dir); err != nil {
fmt.Printf("Failed to download osquery: %v\n", err)
os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests
os.RemoveAll(dir) // explicit removal as defer will not run when os.Exit is called
os.Exit(1) //nolint:forbidigo // Fine to use os.Exit in tests
}

testOsqueryBinary = filepath.Join(dir, "osqueryd")
Expand All @@ -40,7 +40,9 @@ func TestMain(m *testing.M) {

// Run the tests!
retCode := m.Run()
os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit in tests

os.RemoveAll(dir) // explicit removal as defer will not run when os.Exit is called
os.Exit(retCode) //nolint:forbidigo // Fine to use os.Exit in tests
}

func Test_OsqueryRunSqlNoIO(t *testing.T) {
Expand Down

0 comments on commit 293162a

Please sign in to comment.