prysm-pulse/slasher/db/kv/kv_test.go
Victor Farazdagi 2f11e55869
Use t.TempDir() in tests (#7769)
* use t.TempDir()

* remove redundant delete

* simplify setupDB()

* simplify db/testing/setup_db

* fix tests
2020-11-10 22:45:17 +00:00

37 lines
795 B
Go

package kv
import (
"io/ioutil"
"testing"
"github.com/prysmaticlabs/prysm/shared/testutil/require"
"github.com/sirupsen/logrus"
)
func TestMain(m *testing.M) {
logrus.SetLevel(logrus.DebugLevel)
logrus.SetOutput(ioutil.Discard)
m.Run()
}
func setupDB(t testing.TB) *Store {
cfg := &Config{}
db, err := NewKVStore(t.TempDir(), cfg)
require.NoError(t, err, "Failed to instantiate DB")
t.Cleanup(func() {
require.NoError(t, db.Close(), "Failed to close database")
})
return db
}
func setupDBDiffCacheSize(t testing.TB, cacheSize int) *Store {
cfg := &Config{SpanCacheSize: cacheSize}
db, err := NewKVStore(t.TempDir(), cfg)
require.NoError(t, err, "Failed to instantiate DB")
t.Cleanup(func() {
require.NoError(t, db.Close(), "Failed to close database")
})
return db
}