test: use T.TempDir to create temporary test directory

The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2022-02-14 10:38:13 +08:00
parent 5e814afe88
commit b92df1654c
7 changed files with 13 additions and 38 deletions

View File

@@ -2,7 +2,6 @@ package storage
import (
"fmt"
"os"
"testing"
"time"
@@ -12,11 +11,7 @@ import (
)
func TestSearchVolumesWithDeletedNeedles(t *testing.T) {
dir, err := os.MkdirTemp("", "example")
if err != nil {
t.Fatalf("temp dir creation: %v", err)
}
defer os.RemoveAll(dir) // clean up
dir := t.TempDir()
v, err := NewVolume(dir, dir, "", 1, NeedleMapInMemory, &super_block.ReplicaPlacement{}, &needle.TTL{}, 0, 0)
if err != nil {