github.com/prysmaticlabs/prysm@v1.4.4/validator/db/testing/setup_db_test.go (about) 1 package testing 2 3 import ( 4 "context" 5 "os" 6 "path/filepath" 7 "testing" 8 9 "github.com/prysmaticlabs/prysm/shared/testutil/require" 10 "github.com/prysmaticlabs/prysm/validator/db/kv" 11 ) 12 13 func TestClearDB(t *testing.T) { 14 // Setting up manually is required, since SetupDB() will also register a teardown procedure. 15 testDB, err := kv.NewKVStore(context.Background(), t.TempDir(), &kv.Config{ 16 PubKeys: nil, 17 }) 18 require.NoError(t, err, "Failed to instantiate DB") 19 require.NoError(t, testDB.ClearDB()) 20 21 if _, err := os.Stat(filepath.Join(testDB.DatabasePath(), "validator.db")); !os.IsNotExist(err) { 22 t.Fatalf("DB was not cleared: %v", err) 23 } 24 }