kvdb: use T.TempDir to create temporary test directory

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2022-08-15 21:07:05 +08:00
parent d926ad1f84
commit 0edc16aa01
3 changed files with 6 additions and 25 deletions

View File

@@ -1,8 +1,6 @@
package kvdb
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -16,19 +14,12 @@ type boltFixture struct {
}
func NewBoltFixture(t *testing.T) *boltFixture {
tempDir, err := ioutil.TempDir("", "test")
require.NoError(t, err)
return &boltFixture{
t: t,
tempDir: tempDir,
tempDir: t.TempDir(),
}
}
func (b *boltFixture) Cleanup() {
os.RemoveAll(b.tempDir)
}
func (b *boltFixture) NewBackend() walletdb.DB {
dbPath := filepath.Join(b.tempDir)