fix go vet issues and cleanup reader/iterator
This commit is contained in:
parent
f0d282f5f8
commit
1a978a4591
|
@ -151,9 +151,21 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
err := reader.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// get an iterator on a central subset of the data
|
// get an iterator on a central subset of the data
|
||||||
iter := reader.PrefixIterator([]byte("b"))
|
iter := reader.PrefixIterator([]byte("b"))
|
||||||
|
defer func() {
|
||||||
|
err := iter.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// check that all keys have prefix
|
// check that all keys have prefix
|
||||||
found := []string{}
|
found := []string{}
|
||||||
|
@ -162,7 +174,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) {
|
||||||
}
|
}
|
||||||
for _, f := range found {
|
for _, f := range found {
|
||||||
if !strings.HasPrefix(f, "b") {
|
if !strings.HasPrefix(f, "b") {
|
||||||
t.Errorf("got key '%s' that doesn't have correct prefix")
|
t.Errorf("got key '%s' that doesn't have correct prefix", f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(found) != 3 {
|
if len(found) != 3 {
|
||||||
|
@ -176,7 +188,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) {
|
||||||
}
|
}
|
||||||
for _, f := range found {
|
for _, f := range found {
|
||||||
if !strings.HasPrefix(f, "b") {
|
if !strings.HasPrefix(f, "b") {
|
||||||
t.Errorf("got key '%s' that doesn't have correct prefix")
|
t.Errorf("got key '%s' that doesn't have correct prefix", f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(found) != 3 {
|
if len(found) != 3 {
|
||||||
|
@ -190,7 +202,7 @@ func CommonTestPrefixIteratorSeek(t *testing.T, s store.KVStore) {
|
||||||
}
|
}
|
||||||
for _, f := range found {
|
for _, f := range found {
|
||||||
if !strings.HasPrefix(f, "b") {
|
if !strings.HasPrefix(f, "b") {
|
||||||
t.Errorf("got key '%s' that doesn't have correct prefix")
|
t.Errorf("got key '%s' that doesn't have correct prefix", f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(found) != 0 {
|
if len(found) != 0 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user