2019-09-14 07:29:08 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2019-10-07 16:45:01 +00:00
|
|
|
func newBoltStoreForTesting(t *testing.T) Store {
|
2019-09-14 07:29:08 +00:00
|
|
|
testFileName := "test_bolt_db"
|
|
|
|
file, err := ioutil.TempFile("", testFileName)
|
2021-03-01 11:14:15 +00:00
|
|
|
t.Cleanup(func() {
|
2021-07-20 09:06:17 +00:00
|
|
|
err := os.RemoveAll(file.Name())
|
2019-09-14 07:29:08 +00:00
|
|
|
require.NoError(t, err)
|
2021-03-01 11:14:15 +00:00
|
|
|
})
|
2019-09-14 07:29:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.NoError(t, file.Close())
|
2021-07-20 09:06:17 +00:00
|
|
|
boltDBStore, err := NewBoltDBStore(BoltDBOptions{FilePath: file.Name()})
|
2019-09-14 07:29:08 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
return boltDBStore
|
|
|
|
}
|