|
|
@ -2,6 +2,7 @@ package db |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"testing" |
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert" |
|
|
@ -10,7 +11,9 @@ import ( |
|
|
|
func TestDBIteratorSingleKey(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
db.SetSync(bz("1"), bz("value_1")) |
|
|
|
itr := db.Iterator(nil, nil) |
|
|
|
|
|
|
@ -28,7 +31,9 @@ func TestDBIteratorSingleKey(t *testing.T) { |
|
|
|
func TestDBIteratorTwoKeys(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
db.SetSync(bz("1"), bz("value_1")) |
|
|
|
db.SetSync(bz("2"), bz("value_1")) |
|
|
|
|
|
|
@ -54,7 +59,8 @@ func TestDBIteratorTwoKeys(t *testing.T) { |
|
|
|
func TestDBIteratorMany(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
keys := make([][]byte, 100) |
|
|
|
for i := 0; i < 100; i++ { |
|
|
@ -78,7 +84,9 @@ func TestDBIteratorMany(t *testing.T) { |
|
|
|
func TestDBIteratorEmpty(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
itr := db.Iterator(nil, nil) |
|
|
|
|
|
|
|
checkInvalid(t, itr) |
|
|
@ -89,7 +97,9 @@ func TestDBIteratorEmpty(t *testing.T) { |
|
|
|
func TestDBIteratorEmptyBeginAfter(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
itr := db.Iterator(bz("1"), nil) |
|
|
|
|
|
|
|
checkInvalid(t, itr) |
|
|
@ -100,7 +110,9 @@ func TestDBIteratorEmptyBeginAfter(t *testing.T) { |
|
|
|
func TestDBIteratorNonemptyBeginAfter(t *testing.T) { |
|
|
|
for backend := range backends { |
|
|
|
t.Run(fmt.Sprintf("Backend %s", backend), func(t *testing.T) { |
|
|
|
db := newTempDB(t, backend) |
|
|
|
db, dir := newTempDB(t, backend) |
|
|
|
defer os.RemoveAll(dir) |
|
|
|
|
|
|
|
db.SetSync(bz("1"), bz("value_1")) |
|
|
|
itr := db.Iterator(bz("2"), nil) |
|
|
|
|
|
|
|