Change storage to open-close bolt.db to hopefully avoid /tmp files

This commit is contained in:
breel
2020-08-26 17:47:44 -06:00
parent 4aea3dab40
commit 08c1f20ca8
2 changed files with 43 additions and 16 deletions

View File

@@ -369,13 +369,14 @@ func tempBoltDB(t *testing.T) (*BoltDB, func()) {
bdb := NewBoltDB(f.Name())
fillBoltDB(t, bdb)
return bdb, func() {
bdb.db.Close()
os.Remove(f.Name())
}
}
func fillBoltDB(t *testing.T, bdb *BoltDB) {
if err := bdb.db.Update(func(tx *bolt.Tx) error {
db, _ := bdb.db(context.TODO())
defer db.Close()
if err := db.Update(func(tx *bolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists([]byte(testNS))
if err != nil {
return err