working on List

This commit is contained in:
bel
2019-06-21 17:13:18 -06:00
parent 6ac77d247e
commit ade973d19d
13 changed files with 178 additions and 2 deletions

View File

@@ -15,6 +15,14 @@ type mock struct {
m map[string][]byte
}
func (mock *mock) List(ns []string, limits ...string) ([]string, error) {
keys := []string{}
for k := range mock.m {
keys = append(keys, k)
}
return keys, nil
}
func (mock *mock) Get(key string, ns ...string) ([]byte, error) {
namespace := resolveNamespace(ns)
v, ok := mock.m[path.Join(namespace, key)]
@@ -143,6 +151,14 @@ func TestImplementations(t *testing.T) {
t.Errorf("cannot get %T: %v", db, err)
} else if !bytes.Equal(v, validValue) {
t.Errorf("wrong get %T: %q vs %q", db, v, validValue)
} else if keys, err := db.List(nil); err != nil || len(keys) < 1 {
t.Errorf("cannot List(): %v", err)
} else if keys[0] != validKey {
t.Errorf("List()[0] != %s: %s", validKey, keys[0])
} else if keys, err := db.List(nil, validKey[:1]); err != nil || len(keys) < 1 {
t.Errorf("cannot List(prefix): %v", err)
} else if keys[0] != validKey {
t.Errorf("List(prefix)[0] != %s: %s", validKey, keys[0])
} else {
t.Logf("%25T GET: %s", db, v)
}