mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-07 06:37:17 +02:00
fix: os.MkdirTemp with t.TempDir (#15860)
Signed-off-by: Surya Prakash <surya0prakash@proton.me>
This commit is contained in:
parent
3389cdf957
commit
cb3b17a14c
@ -60,11 +60,7 @@ func TestDirLockerUsage(t *testing.T, open func(t *testing.T, data string, creat
|
|||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
t.Run(fmt.Sprintf("%+v", c), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%+v", c), func(t *testing.T) {
|
||||||
tmpdir, err := os.MkdirTemp("", "test")
|
tmpdir := t.TempDir()
|
||||||
require.NoError(t, err)
|
|
||||||
t.Cleanup(func() {
|
|
||||||
require.NoError(t, os.RemoveAll(tmpdir))
|
|
||||||
})
|
|
||||||
|
|
||||||
// Test preconditions (file already exists + lockfile option)
|
// Test preconditions (file already exists + lockfile option)
|
||||||
if c.fileAlreadyExists {
|
if c.fileAlreadyExists {
|
||||||
@ -82,7 +78,7 @@ func TestDirLockerUsage(t *testing.T, open func(t *testing.T, data string, creat
|
|||||||
|
|
||||||
// Check that the lockfile is always deleted
|
// Check that the lockfile is always deleted
|
||||||
if !c.lockFileDisabled {
|
if !c.lockFileDisabled {
|
||||||
_, err = os.Stat(locker.path)
|
_, err := os.Stat(locker.path)
|
||||||
require.True(t, os.IsNotExist(err), "lockfile was not deleted")
|
require.True(t, os.IsNotExist(err), "lockfile was not deleted")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user