htlcswitch: 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 committed 2022-08-24 09:03:01 +08:00
1 parent 4f1e4ff87a
commit 9294b53fcc
5 files changed
+43 -78

No files matched your search

+3 -11
View File
@@ -1,8 +1,6 @@
package htlcswitch
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -40,20 +38,14 @@ func TestInsertAndDelete(t *testing.T) {
// Create the backend database and use it to create the resolution
// store.
dbDir, err := ioutil.TempDir("", "resolutionStore")
require.NoError(t, err)
dbPath := filepath.Join(dbDir, "testdb")
dbPath := filepath.Join(t.TempDir(), "testdb")
db, err := kvdb.Create(
kvdb.BoltBackendName, dbPath, true, kvdb.DefaultDBTimeout,
)
require.NoError(t, err)
cleanUp := func() {
t.Cleanup(func() {
db.Close()
os.RemoveAll(dbDir)
}
defer cleanUp()
})
resStore := newResolutionStore(db)