neoneo-go/pkg/core/storage/boltdb_store_test.go
Roman Khimov 3b19b34122 storage: fix memcached test with boltdb store
Everything was wrong here, wrong file used, wrong cleanup procedure, the net
result is this (and some failing tests from time to time):

  $ ls -l /tmp/test_bolt_db* | wc -l
  30939
2021-07-20 12:35:24 +03:00

23 lines
494 B
Go

package storage
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func newBoltStoreForTesting(t *testing.T) Store {
testFileName := "test_bolt_db"
file, err := ioutil.TempFile("", testFileName)
t.Cleanup(func() {
err := os.RemoveAll(file.Name())
require.NoError(t, err)
})
require.NoError(t, err)
require.NoError(t, file.Close())
boltDBStore, err := NewBoltDBStore(BoltDBOptions{FilePath: file.Name()})
require.NoError(t, err)
return boltDBStore
}