Skip to content

Commit cb3b17a

Browse files
fix: os.MkdirTemp with t.TempDir (prometheus#15860)
Signed-off-by: Surya Prakash <surya0prakash@proton.me>
1 parent 3389cdf commit cb3b17a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

tsdb/tsdbutil/dir_locker_testutil.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ func TestDirLockerUsage(t *testing.T, open func(t *testing.T, data string, creat
6060

6161
for _, c := range cases {
6262
t.Run(fmt.Sprintf("%+v", c), func(t *testing.T) {
63-
tmpdir, err := os.MkdirTemp("", "test")
64-
require.NoError(t, err)
65-
t.Cleanup(func() {
66-
require.NoError(t, os.RemoveAll(tmpdir))
67-
})
63+
tmpdir := t.TempDir()
6864

6965
// Test preconditions (file already exists + lockfile option)
7066
if c.fileAlreadyExists {
@@ -82,7 +78,7 @@ func TestDirLockerUsage(t *testing.T, open func(t *testing.T, data string, creat
8278

8379
// Check that the lockfile is always deleted
8480
if !c.lockFileDisabled {
85-
_, err = os.Stat(locker.path)
81+
_, err := os.Stat(locker.path)
8682
require.True(t, os.IsNotExist(err), "lockfile was not deleted")
8783
}
8884
})

0 commit comments

Comments
 (0)