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

Unified Diff: impl/memory/datastore_query_execution_test.go

Issue 1892343002: Add __namespace__ metadata query support to impl/memory. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Add comment Created 4 years, 8 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') | service/datastore/query.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 6f7183b20e0ede2bbbacd208e425f059451b980c..41f4a898b2356b8466cb60cbffd3699ff14d83cc 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -85,6 +85,8 @@ var stage2Data = []ds.PropertyMap{
"Val", 3, 4, 2, 1, Next,
"Extra", "nuts",
),
+ pmap("$key", ds.MakeKey("dev~app", "", "Kind", "id")),
+ pmap("$key", ds.MakeKey("dev~app", "bob", "Kind", "id")),
}
var collapsedData = []ds.PropertyMap{
@@ -146,6 +148,11 @@ var queryExecutionTests = []qExTest{
{q: nq("Child").Ancestor(key("Kind", 3)), keys: []*ds.Key{
key("Kind", 3, "Child", "seven"),
}, inTxn: true},
+ {q: nq("__namespace__"), get: []ds.PropertyMap{
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "ns")),
+ }},
+ {q: nq("__namespace__").Offset(1), get: []ds.PropertyMap{}},
+ {q: nq("__namespace__").Offset(1).Limit(1), get: []ds.PropertyMap{}},
},
},
@@ -343,6 +350,18 @@ var queryExecutionTests = []qExTest{
stage1Data[3],
stage1Data[2],
}},
+ {q: nq("__namespace__"), get: []ds.PropertyMap{
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", 1)),
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "bob")),
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "ns")),
+ }},
+ {q: nq("__namespace__").Offset(1), get: []ds.PropertyMap{
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "bob")),
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "ns")),
+ }},
+ {q: nq("__namespace__").Offset(1).Limit(1), get: []ds.PropertyMap{
+ pmap("$key", ds.MakeKey("dev~app", "", "__namespace__", "bob")),
+ }},
},
extraFns: []func(context.Context){
@@ -487,10 +506,19 @@ func TestQueryExecution(t *testing.T) {
testing.CatchupIndexes()
testing.AddIndexes(stage.addIdxs...)
- if err := data.PutMulti(stage.putEnts); err != nil {
- // prevent Convey from thinking this assertion should show up in
- // every test loop.
- panic(err)
+ byNs := map[string][]ds.PropertyMap{}
+ for _, ent := range stage.putEnts {
+ k := ds.GetMetaDefault(ent, "key", nil).(*ds.Key)
+ byNs[k.Namespace()] = append(byNs[k.Namespace()], ent)
+ }
+ for ns, ents := range byNs {
+ c := info.Get(c).MustNamespace(ns)
+ data := ds.Get(c)
+ if err := data.PutMulti(ents); err != nil {
+ // prevent Convey from thinking this assertion should show up in
+ // every test loop.
+ panic(err)
+ }
}
if err := data.DeleteMulti(stage.delEnts); err != nil {
« no previous file with comments | « impl/memory/datastore_query_execution.go ('k') | service/datastore/query.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698