arnaucube
arnaucube/arboPublic Self-hosted repository
arbo/db/goleveldb/goleveldb_test.go
db/goleveldb/goleveldb_test.goRaw
 1package goleveldb
 2
 3import (
 4	"testing"
 5
 6	"github.com/arnaucube/arbo/db"
 7	"github.com/arnaucube/arbo/db/internal/dbtest"
 8	"github.com/arnaucube/arbo/db/prefixeddb"
 9	qt "github.com/frankban/quicktest"
10)
11
12func TestWriteTx(t *testing.T) {
13	database, err := New(db.Options{Path: t.TempDir()})
14	qt.Assert(t, err, qt.IsNil)
15
16	dbtest.TestWriteTx(t, database)
17}
18
19func TestIterate(t *testing.T) {
20	database, err := New(db.Options{Path: t.TempDir()})
21	qt.Assert(t, err, qt.IsNil)
22
23	dbtest.TestIterate(t, database)
24}
25
26func TestWriteTxApply(t *testing.T) {
27	database, err := New(db.Options{Path: t.TempDir()})
28	qt.Assert(t, err, qt.IsNil)
29
30	dbtest.TestWriteTxApply(t, database)
31}
32
33func TestWriteTxApplyPrefixed(t *testing.T) {
34	database, err := New(db.Options{Path: t.TempDir()})
35	qt.Assert(t, err, qt.IsNil)
36
37	prefix := []byte("one")
38	dbWithPrefix := prefixeddb.NewPrefixedDatabase(database, prefix)
39
40	dbtest.TestWriteTxApplyPrefixed(t, database, dbWithPrefix)
41}
42
43// NOTE: This test fails.  pebble.Batch doesn't detect conflicts.  Moreover,
44// reads from a pebble.Batch return the last version from the Database, even if
45// the update was made after the pebble.Batch was created.  Basically it's not
46// a Transaction, but a Batch of write operations.
47// func TestConcurrentWriteTx(t *testing.T) {
48// 	database, err := New(db.Options{Path: t.TempDir()})
49// 	qt.Assert(t, err, qt.IsNil)
50//
51// 	dbtest.TestConcurrentWriteTx(t, database)
52// }