diff options
Diffstat (limited to 'internal/testhelpers/tmpdir.go')
-rw-r--r-- | internal/testhelpers/tmpdir.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/internal/testhelpers/tmpdir.go b/internal/testhelpers/tmpdir.go index de104a04..d5d4d165 100644 --- a/internal/testhelpers/tmpdir.go +++ b/internal/testhelpers/tmpdir.go @@ -2,7 +2,6 @@ package testhelpers import ( "context" - "os" "path/filepath" "testing" @@ -14,11 +13,11 @@ import ( var fs = vfs.Instrumented(&local.VFS{}) -func TmpDir(tb testing.TB, pattern string) (vfs.Root, string) { +func TmpDir(tb testing.TB) (vfs.Root, string) { tb.Helper() - tmpDir, err := os.MkdirTemp("", pattern) - require.NoError(tb, err) + var err error + tmpDir := tb.TempDir() // On some systems `/tmp` can be a symlink tmpDir, err = filepath.EvalSymlinks(tmpDir) @@ -27,9 +26,5 @@ func TmpDir(tb testing.TB, pattern string) (vfs.Root, string) { root, err := fs.Root(context.Background(), tmpDir, "") require.NoError(tb, err) - tb.Cleanup(func() { - require.NoError(tb, os.RemoveAll(tmpDir)) - }) - return root, tmpDir } |