Skip to content

Commit

Permalink
Fix BadgerDB tests only test the bbolt implementation
Browse files Browse the repository at this point in the history
- When working on the BadgerDB implementation (#16) I copied the bbolt implementation and tests and must have forgotten to adapt the tests
  • Loading branch information
philippgille committed Nov 6, 2018
1 parent 7ad9963 commit 99f147c
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions badgerdb/badgerdb_test.go
Expand Up @@ -7,16 +7,16 @@ import (
"sync"
"testing"

"github.com/philippgille/gokv/bolt"
"github.com/philippgille/gokv/badgerdb"
"github.com/philippgille/gokv/test"
)

// TestStore tests if reading and writing to the store works properly.
func TestStore(t *testing.T) {
options := bolt.Options{
Path: generateRandomTempDbPath(t),
options := badgerdb.Options{
Dir: generateRandomTempDBpath(t),
}
store, err := bolt.NewStore(options)
store, err := badgerdb.NewStore(options)
if err != nil {
t.Error(err)
}
Expand All @@ -26,12 +26,12 @@ func TestStore(t *testing.T) {

// TestStoreConcurrent launches a bunch of goroutines that concurrently work with one store.
// The store works with a single file, so everything should be locked properly.
// The locking is implemented in the bbolt package, but test it nonetheless.
// The locking is implemented in the BadgerDB package, but test it nonetheless.
func TestStoreConcurrent(t *testing.T) {
options := bolt.Options{
Path: generateRandomTempDbPath(t),
options := badgerdb.Options{
Dir: generateRandomTempDBpath(t),
}
store, err := bolt.NewStore(options)
store, err := badgerdb.NewStore(options)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -63,11 +63,10 @@ func TestStoreConcurrent(t *testing.T) {
}
}

func generateRandomTempDbPath(t *testing.T) string {
path, err := ioutil.TempDir(os.TempDir(), "bolt")
func generateRandomTempDBpath(t *testing.T) string {
path, err := ioutil.TempDir(os.TempDir(), "BadgerDB")
if err != nil {
t.Errorf("Generating random DB path failed: %v", err)
}
path += "/bolt.db"
return path
}

0 comments on commit 99f147c

Please sign in to comment.