plugin: use t.TempDir

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-04-22 10:53:56 +02:00
parent 57b27f2e9e
commit 02e800dcbb
2 changed files with 6 additions and 20 deletions

View File

@@ -7,11 +7,7 @@ import (
)
func TestAtomicRemoveAllNormal(t *testing.T) {
dir, err := os.MkdirTemp("", "atomic-remove-with-normal")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir) // just try to make sure this gets cleaned up
dir := t.TempDir()
if err := atomicRemoveAll(dir); err != nil {
t.Fatal(err)
@@ -26,11 +22,7 @@ func TestAtomicRemoveAllNormal(t *testing.T) {
}
func TestAtomicRemoveAllAlreadyExists(t *testing.T) {
dir, err := os.MkdirTemp("", "atomic-remove-already-exists")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir) // just try to make sure this gets cleaned up
dir := t.TempDir()
if err := os.MkdirAll(dir+"-removing", 0o755); err != nil {
t.Fatal(err)
@@ -54,11 +46,7 @@ func TestAtomicRemoveAllNotExist(t *testing.T) {
t.Fatal(err)
}
dir, err := os.MkdirTemp("", "atomic-remove-already-exists")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir) // just try to make sure this gets cleaned up
dir := t.TempDir()
// create the removing dir, but not the "real" one
foo := filepath.Join(dir, "foo")

View File

@@ -23,11 +23,9 @@ import (
func TestManagerWithPluginMounts(t *testing.T) {
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
root, err := os.MkdirTemp("", "test-store-with-plugin-mounts")
if err != nil {
t.Fatal(err)
}
defer containerfs.EnsureRemoveAll(root)
root := t.TempDir()
t.Cleanup(func() { _ = containerfs.EnsureRemoveAll(root) })
s := NewStore()
managerRoot := filepath.Join(root, "manager")