Memory and file store list fixes (#1959)

* Refactor file and memory stores
This commit is contained in:
Dominic Wong
2020-08-20 15:08:35 +01:00
committed by GitHub
parent 329bc2f265
commit 78a79ca9e1
3 changed files with 121 additions and 154 deletions

View File

@@ -264,6 +264,15 @@ func listTests(s store.Store, t *testing.T) {
t.Fatalf("Expected 2 records, received %d %+v", len(recs), recs)
}
for i := 0; i < 10; i++ {
s.Write(&store.Record{Key: fmt.Sprintf("ListOffset%d", i), Value: []byte("bar")})
}
recs, err = s.List(store.ListPrefix("ListOffset"), store.ListOffset(6))
if len(recs) != 4 {
t.Fatalf("Expected 4 records, received %d %+v", len(recs), recs)
}
}
func expiryTests(s store.Store, t *testing.T) {
@@ -306,7 +315,7 @@ func expiryTests(s store.Store, t *testing.T) {
t.Error(err)
}
if len(results) != 3 {
t.Fatal("Results should have returned 3 records")
t.Fatalf("Results should have returned 3 records, returned %d", len(results))
}
time.Sleep(1 * time.Second)
results, err = s.Read("a", store.ReadPrefix())