diff --git a/db/db_pebble_test.go b/db/db_pebble_test.go index 3cdf02907a..2da84de767 100644 --- a/db/db_pebble_test.go +++ b/db/db_pebble_test.go @@ -7,14 +7,12 @@ package db import ( "context" - "os" "testing" "github.com/pkg/errors" "github.com/stretchr/testify/require" "github.com/iotexproject/iotex-core/v2/db/batch" - "github.com/iotexproject/iotex-core/v2/testutil" ) type kvTest struct { @@ -24,11 +22,7 @@ type kvTest struct { func TestPebbleDB(t *testing.T) { r := require.New(t) - testPath, err := os.MkdirTemp("", "test-pebble") - r.NoError(err) - defer func() { - testutil.CleanupPath(testPath) - }() + testPath := t.TempDir() cfg := DefaultConfig cfg.DbPath = testPath @@ -131,11 +125,7 @@ func TestPebbleDB(t *testing.T) { func TestPebbleDB_Filter(t *testing.T) { r := require.New(t) - testPath, err := os.MkdirTemp("", "test-pebble") - r.NoError(err) - defer func() { - testutil.CleanupPath(testPath) - }() + testPath := t.TempDir() cfg := DefaultConfig cfg.DbPath = testPath @@ -189,11 +179,7 @@ func TestPebbleDB_Filter(t *testing.T) { func TestPebbleDB_Foreach(t *testing.T) { r := require.New(t) - testPath, err := os.MkdirTemp("", "test-pebble") - r.NoError(err) - defer func() { - testutil.CleanupPath(testPath) - }() + testPath := t.TempDir() cfg := DefaultConfig cfg.DbPath = testPath diff --git a/server/itx/server_test.go b/server/itx/server_test.go index ae21e6f942..61d308ace7 100644 --- a/server/itx/server_test.go +++ b/server/itx/server_test.go @@ -7,7 +7,6 @@ package itx import ( "context" - "os" "testing" "time" @@ -84,8 +83,7 @@ func newConfig(t *testing.T) (config.Config, func()) { require.NoError(err) contractIndexPath, err := testutil.PathOfTempFile("contractindxer.db") require.NoError(err) - testActionStorePath, err := os.MkdirTemp(os.TempDir(), "actionstore") - require.NoError(err) + testActionStorePath := t.TempDir() cfg := config.Default cfg.Genesis = genesis.TestDefault() cfg.API.GRPCPort = testutil.RandomPort()