Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: impl/memory/datastore_query_execution_test.go

Issue 1380613002: Fix bugs in impl/memory queries. (Closed) Base URL: https://github.com/luci/gae.git@add_appid
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/datastore_query_execution.go ('k') | impl/memory/gkvlite_iter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_query_execution_test.go
diff --git a/impl/memory/datastore_query_execution_test.go b/impl/memory/datastore_query_execution_test.go
index fe1fcbe948b43905d95a565f8da4dfa0037cb19c..b358051a761b37d2c9331c222c6f6f79721639b0 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -57,7 +57,7 @@ var stage1Data = []ds.PropertyMap{
"Extra", "waffle",
),
pmap("$key", key("Kind", 6), Next,
- "Val", 5, Next,
+ "Val", 5, 3, 2, Next,
"When", time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC), Next,
"Extra", "waffle",
),
@@ -153,17 +153,57 @@ var queryExecutionTests = []qExTest{
stage1Data[4],
}},
- {q: (nq("Kind").Ancestor(key("Kind", 3)).Order("Val").
- Start(curs("Val", 1, "__key__", key("Kind", 3))).
- End(curs("Val", 90, "__key__", key("Kind", 3, "Zeta", "woot")))), keys: []*ds.Key{},
+ {q: nq("Kind").Eq("Val", 2, 3), get: []ds.PropertyMap{
+ stage1Data[0],
+ stage1Data[3],
+ }},
+
+ // note the kind :)
+ {q: (nq("Kind").Ancestor(key("Kind", 3)).
+ Start(curs("__key__", key("Kind", 3))).
+ End(curs("__key__", key("Kind", 3, "Zeta", "woot")))),
+ keys: []*ds.Key{
+ key("Kind", 3),
+ key("Kind", 3, "Kind", 1),
+ key("Kind", 3, "Kind", 2),
+ key("Kind", 3, "Kind", 3),
+ },
+ },
+
+ {q: (nq("").Ancestor(key("Kind", 3)).
+ Start(curs("__key__", key("Kind", 3))).
+ End(curs("__key__", key("Kind", 3, "Zeta", "woot")))),
+ keys: []*ds.Key{
+ key("Kind", 3),
+ key("Kind", 3, "Child", "seven"),
+ key("Kind", 3, "Kind", 1),
+ key("Kind", 3, "Kind", 2),
+ key("Kind", 3, "Kind", 3),
+ },
},
- {q: (nq("Kind").Ancestor(key("Kind", 3)).Order("Val").
- Start(curs("Val", 1, "__key__", key("Kind", 3))).
- End(curs("Val", 90, "__key__", key("Kind", 3, "Zeta", "woot")))),
- keys: []*ds.Key{},
+ {q: (nq("Kind").Ancestor(key("Kind", 3)).
+ Start(curs("__key__", key("Kind", 3))).
+ End(curs("__key__", key("Kind", 3, "Zeta", "woot")))),
+ keys: []*ds.Key{
+ key("Kind", 3),
+ key("Kind", 3, "Kind", 1),
+ key("Kind", 3, "Kind", 2),
+ key("Kind", 3, "Kind", 3),
+ },
inTxn: true},
+ {q: nq("Kind").Ancestor(key("Kind", 3)).Eq("Val", 3, 4),
+ keys: []*ds.Key{
+ key("Kind", 3, "Kind", 2),
+ key("Kind", 3, "Kind", 3),
+ },
+ get: []ds.PropertyMap{
+ stage2Data[1],
+ stage2Data[2],
+ },
+ },
+
{q: nq("Kind").Gt("Val", 2).Lte("Val", 5), get: []ds.PropertyMap{
stage1Data[0], stage1Data[3],
}},
@@ -318,6 +358,20 @@ var queryExecutionTests = []qExTest{
" direction: desc",
}, "\n"))
},
+
+ func(c context.Context) {
+ data := ds.Get(c)
+ q := nq("Something").Ancestor(key("Kind", 3)).Order("Val")
+ So(data.Run(q, func(ds.Key, ds.CursorCB) bool {
+ return true
+ }), ShouldErrLike, strings.Join([]string{
+ "Consider adding:",
+ "- kind: Something",
+ " ancestor: yes",
+ " properties:",
+ " - name: Val",
+ }, "\n"))
+ },
},
},
« no previous file with comments | « impl/memory/datastore_query_execution.go ('k') | impl/memory/gkvlite_iter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698