Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -7,11 +7,7 @@ import ( |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
func TestAtomicRemoveAllNormal(t *testing.T) {
|
| 10 |
- dir, err := os.MkdirTemp("", "atomic-remove-with-normal")
|
|
| 11 |
- if err != nil {
|
|
| 12 |
- t.Fatal(err) |
|
| 13 |
- } |
|
| 14 |
- defer os.RemoveAll(dir) // just try to make sure this gets cleaned up |
|
| 10 |
+ dir := t.TempDir() |
|
| 15 | 11 |
|
| 16 | 12 |
if err := atomicRemoveAll(dir); err != nil {
|
| 17 | 13 |
t.Fatal(err) |
| ... | ... |
@@ -26,11 +22,7 @@ func TestAtomicRemoveAllNormal(t *testing.T) {
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
func TestAtomicRemoveAllAlreadyExists(t *testing.T) {
|
| 29 |
- dir, err := os.MkdirTemp("", "atomic-remove-already-exists")
|
|
| 30 |
- if err != nil {
|
|
| 31 |
- t.Fatal(err) |
|
| 32 |
- } |
|
| 33 |
- defer os.RemoveAll(dir) // just try to make sure this gets cleaned up |
|
| 29 |
+ dir := t.TempDir() |
|
| 34 | 30 |
|
| 35 | 31 |
if err := os.MkdirAll(dir+"-removing", 0o755); err != nil {
|
| 36 | 32 |
t.Fatal(err) |
| ... | ... |
@@ -54,11 +46,7 @@ func TestAtomicRemoveAllNotExist(t *testing.T) {
|
| 54 | 54 |
t.Fatal(err) |
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 |
- dir, err := os.MkdirTemp("", "atomic-remove-already-exists")
|
|
| 58 |
- if err != nil {
|
|
| 59 |
- t.Fatal(err) |
|
| 60 |
- } |
|
| 61 |
- defer os.RemoveAll(dir) // just try to make sure this gets cleaned up |
|
| 57 |
+ dir := t.TempDir() |
|
| 62 | 58 |
|
| 63 | 59 |
// create the removing dir, but not the "real" one |
| 64 | 60 |
foo := filepath.Join(dir, "foo") |
| ... | ... |
@@ -23,11 +23,9 @@ import ( |
| 23 | 23 |
|
| 24 | 24 |
func TestManagerWithPluginMounts(t *testing.T) {
|
| 25 | 25 |
skip.If(t, os.Getuid() != 0, "skipping test that requires root") |
| 26 |
- root, err := os.MkdirTemp("", "test-store-with-plugin-mounts")
|
|
| 27 |
- if err != nil {
|
|
| 28 |
- t.Fatal(err) |
|
| 29 |
- } |
|
| 30 |
- defer containerfs.EnsureRemoveAll(root) |
|
| 26 |
+ |
|
| 27 |
+ root := t.TempDir() |
|
| 28 |
+ t.Cleanup(func() { _ = containerfs.EnsureRemoveAll(root) })
|
|
| 31 | 29 |
|
| 32 | 30 |
s := NewStore() |
| 33 | 31 |
managerRoot := filepath.Join(root, "manager") |