Skip to content

test cleanup improvements #2015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 28, 2025
Merged
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
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
Loading