Update test to account for nested mounts

parent 0ab21bf7
......@@ -297,6 +297,55 @@ func TestQueryCross(t *testing.T) {
}
}
func TestQueryCrossWithSort(t *testing.T) {
mapds0 := datastore.NewMapDatastore()
mapds1 := datastore.NewMapDatastore()
mapds2 := datastore.NewMapDatastore()
m := mount.New([]mount.Mount{
{Prefix: datastore.NewKey("/zoo"), Datastore: mapds1},
{Prefix: datastore.NewKey("/boo/5"), Datastore: mapds2},
{Prefix: datastore.NewKey("/boo"), Datastore: mapds0},
})
m.Put(datastore.NewKey("/zoo/0"), []byte("123"))
m.Put(datastore.NewKey("/zoo/1"), []byte("234"))
m.Put(datastore.NewKey("/boo/9"), []byte("345"))
m.Put(datastore.NewKey("/boo/3"), []byte("456"))
m.Put(datastore.NewKey("/boo/5/hello"), []byte("789"))
res, err := m.Query(query.Query{Orders: []query.Order{query.OrderByKey{}}})
if err != nil {
t.Fatalf("Query fail: %v\n", err)
}
entries, err := res.Rest()
if err != nil {
t.Fatalf("Query Results.Rest fail: %v\n", err)
}
expect := []string{
"/boo/3",
"/boo/5/hello",
"/boo/9",
"/zoo/0",
"/zoo/1",
}
if len(entries) != len(expect) {
t.Fatalf("expected %d entries, but got %d", len(expect), len(entries))
}
for i, e := range expect {
if e != entries[i].Key {
t.Errorf("expected key %s, but got %s", e, entries[i].Key)
}
}
err = res.Close()
if err != nil {
t.Errorf("result.Close failed %d", err)
}
}
func TestLookupPrio(t *testing.T) {
mapds0 := datastore.NewMapDatastore()
mapds1 := datastore.NewMapDatastore()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment