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:
@@ -64,9 +64,7 @@ func TestPodHostname(t *testing.T) {
|
||||
if test.needsHostNetwork && goruntime.GOOS == "windows" {
|
||||
t.Skip("Skipped on Windows.")
|
||||
}
|
||||
testPodLogDir, err := os.MkdirTemp("", "hostname")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(testPodLogDir)
|
||||
testPodLogDir := t.TempDir()
|
||||
|
||||
opts := append(test.opts, WithPodLogDirectory(testPodLogDir))
|
||||
t.Log("Create a sandbox with hostname")
|
||||
|
||||
Reference in New Issue
Block a user