mirror of
https://github.com/aljazceru/kata-containers.git
synced 2025-12-23 17:24:18 +01:00
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. This commit also updates the unit test advice to use `T.TempDir` to create temporary directory in tests. Fixes: #3924 Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -51,11 +51,8 @@ func TestGzipAccepted(t *testing.T) {
|
||||
|
||||
func TestEnsureDir(t *testing.T) {
|
||||
const testMode = 0755
|
||||
tmpdir, err := os.MkdirTemp("", "TestEnsureDir")
|
||||
assert := assert.New(t)
|
||||
|
||||
assert.NoError(err)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
// nolint: govet
|
||||
testCases := []struct {
|
||||
@@ -120,9 +117,7 @@ func TestEnsureDir(t *testing.T) {
|
||||
|
||||
func TestFirstValidExecutable(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
tmpdir, err := os.MkdirTemp("", "TestFirstValidPath")
|
||||
assert.NoError(err)
|
||||
defer os.RemoveAll(tmpdir)
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
// nolint: govet
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user