Skip to content

Commit

Permalink
cleanup tmpdir
Browse files Browse the repository at this point in the history
  • Loading branch information
sreya committed Nov 27, 2024
1 parent b6eb32d commit 9db34a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion integration/integrationtest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ func TmpDir(t *testing.T) string {
// We use os.MkdirTemp as oposed to t.TempDir since the envbox container will
// chown some of the created directories here to root:root causing the cleanup
// function to fail once the test exits.
tmpdir, err := os.MkdirTemp("", strings.ReplaceAll(t.Name(), "/", "_"))
tmpdir, err := os.MkdirTemp(os.TempDir(), strings.ReplaceAll(t.Name(), "/", "_"))
require.NoError(t, err)
t.Logf("using tmpdir %s", tmpdir)
t.Cleanup(func() {
if !t.Failed() {
// Could be useful in case of test failure.
_ = os.RemoveAll(tmpdir)
}
})
return tmpdir
}

Expand Down

0 comments on commit 9db34a0

Please sign in to comment.