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 0c9399632299ab524033dcdc94b1e620ce675b45..e71c0db05d1cc11e22128d55a7b88347a6e95dbd 100644 |
--- a/impl/memory/datastore_query_execution_test.go |
+++ b/impl/memory/datastore_query_execution_test.go |
@@ -23,6 +23,13 @@ func mkKey(appID, namespace string, elems ...interface{}) *ds.Key { |
return ds.MkKeyContext(appID, namespace).MakeKey(elems...) |
} |
+var enableOnly = false |
+ |
+func enable() bool { |
dnj
2016/11/11 08:37:53
This is something useful for debugging specific te
|
+ enableOnly = true |
+ return true |
+} |
+ |
type qExpect struct { |
q *ds.Query |
inTxn bool |
@@ -30,6 +37,8 @@ type qExpect struct { |
get []ds.PropertyMap |
keys []*ds.Key |
count int |
+ |
+ enable bool |
} |
type qExStage struct { |
@@ -252,9 +261,7 @@ var queryExecutionTests = []qExTest{ |
}}, |
{q: nq("").Gt("__key__", key("Kind", 2)), |
- // count counts from the index with KeysOnly and so counts the deleted |
dnj
2016/11/11 08:37:53
(This is no longer true, since we don't auto-KeysO
|
- // entity Unique/1. |
- count: 8, |
+ count: 7, |
get: []ds.PropertyMap{ |
// TODO(riannucci): determine if the real datastore shows metadata |
// during kindless queries. The documentation seems to imply so, but |
@@ -423,9 +430,10 @@ var queryExecutionTests = []qExTest{ |
expect: []qExpect{ |
// eventual consistency; Unique/1 is deleted at HEAD. Keysonly finds it, |
// but 'normal' doesn't. |
+ {q: nq("Unique").Gt("__key__", key("AKind", 5)).Lte("__key__", key("Zeta", "prime")).KeysOnly(true), |
+ keys: []*ds.Key{key("Unique", 1)}}, |
{q: nq("Unique").Gt("__key__", key("AKind", 5)).Lte("__key__", key("Zeta", "prime")), |
- keys: []*ds.Key{key("Unique", 1)}, |
- get: []ds.PropertyMap{}}, |
+ get: []ds.PropertyMap{}}, |
{q: nq("Kind").Eq("Val", 1, 3), get: []ds.PropertyMap{ |
stage1Data[0], stage2Data[2], |
@@ -483,6 +491,33 @@ var queryExecutionTests = []qExTest{ |
}, |
}, |
}}, |
+ |
+ {"regression: tombstones and limit/offset queries", []qExStage{ |
+ { |
+ putEnts: []ds.PropertyMap{ |
+ pmap("$key", key("Kind", 1)), |
+ pmap("$key", key("Kind", 2)), |
+ pmap("$key", key("Kind", 3)), |
+ }, |
+ delEnts: []*ds.Key{key("Kind", 2)}, |
+ }, |
+ { |
+ expect: []qExpect{ |
+ { |
+ q: nq("Kind").Limit(2), |
+ get: []ds.PropertyMap{ |
+ pmap("$key", key("Kind", 1)), |
+ pmap("$key", key("Kind", 3)), |
+ }, |
+ }, |
+ |
+ { |
+ q: nq("Kind").Offset(2), |
+ get: []ds.PropertyMap{}, |
+ }, |
+ }, |
+ }, |
+ }}, |
} |
func TestQueryExecution(t *testing.T) { |
@@ -526,6 +561,9 @@ func TestQueryExecution(t *testing.T) { |
Convey(fmt.Sprintf("stage %d", i), func() { |
for j, expect := range stage.expect { |
+ if enableOnly && !expect.enable { |
+ continue |
+ } |
runner := func(c context.Context, f func(ic context.Context) error, _ *ds.TransactionOptions) error { |
return f(c) |
} |