From 1cd7e3aee62a4882331a79c75d14feffb13148e8 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Mon, 15 Aug 2022 21:04:39 +0800 Subject: [PATCH] aliasmgr: use `T.TempDir` to create temporary test directory Signed-off-by: Eng Zer Jun --- aliasmgr/aliasmgr_test.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/aliasmgr/aliasmgr_test.go b/aliasmgr/aliasmgr_test.go index 291acd9c3..9ae7f82df 100644 --- a/aliasmgr/aliasmgr_test.go +++ b/aliasmgr/aliasmgr_test.go @@ -1,9 +1,7 @@ package aliasmgr import ( - "io/ioutil" "math/rand" - "os" "path/filepath" "testing" @@ -18,11 +16,7 @@ func TestAliasStorePeerAlias(t *testing.T) { t.Parallel() // Create the backend database and use this to create the aliasStore. - dbDir, err := ioutil.TempDir("", "aliasStore") - require.NoError(t, err) - defer os.RemoveAll(dbDir) - - dbPath := filepath.Join(dbDir, "testdb") + dbPath := filepath.Join(t.TempDir(), "testdb") db, err := kvdb.Create( kvdb.BoltBackendName, dbPath, true, kvdb.DefaultDBTimeout, ) @@ -51,11 +45,7 @@ func TestAliasStoreRequest(t *testing.T) { t.Parallel() // Create the backend database and use this to create the aliasStore. - dbDir, err := ioutil.TempDir("", "aliasStore") - require.NoError(t, err) - defer os.RemoveAll(dbDir) - - dbPath := filepath.Join(dbDir, "testdb") + dbPath := filepath.Join(t.TempDir(), "testdb") db, err := kvdb.Create( kvdb.BoltBackendName, dbPath, true, kvdb.DefaultDBTimeout, )