Skip to content
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

test cleanup improvements #2015

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 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.Remove(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,6 +40,8 @@ func TestMain(m *testing.M) {

// Run the tests!
retCode := m.Run()

os.Remove(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
}

Expand Down
Loading