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 committed 2022-02-14 10:38:13 +08:00
1 parent 5e814afe88
commit b92df1654c
7 files changed
+13 -38

No files matched your search

@@ -4,14 +4,11 @@ import (
"bytes"
"fmt"
"math/rand"
"os"
"testing"
)
func TestOnDisk(t *testing.T) {
tmpDir, _ := os.MkdirTemp("", "c")
defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()
totalDiskSizeInKB := int64(32)