Skip to content

Commit

Permalink
test: ensure fixtures directory isn't already a git repository (#426)
Browse files Browse the repository at this point in the history
Currently if the test suite is exited prematurely by a ctrl+c or if it
runs badly such as due to invalid flags being passed, it'll not properly
do its cleanup - this'll then cause the suite to fail with a panic until
the `.git` directory is manually removed from
`.cmd/osv-scanner/fixtures`.
  • Loading branch information
G-Rath committed Jun 28, 2023
1 parent df210dd commit 3880e72
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/osv-scanner/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,10 @@ func TestRun_LockfileWithExplicitParseAs(t *testing.T) {
}

func TestMain(m *testing.M) {
// ensure a git repository doesn't already exist in the fixtures directory,
// in case we didn't get a chance to clean-up properly in the last run
os.RemoveAll("./fixtures/.git")

// Temporarily make the fixtures folder a git repository to prevent gitignore files messing with tests.
_, err := git.PlainInit("./fixtures", false)
if err != nil {
Expand Down

0 comments on commit 3880e72

Please sign in to comment.