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

Unified Diff: impl/memory/datastore_query_execution_test.go

Issue 1550903002: impl/memory: Fix time serialization encoding. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Created 5 years 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
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 2a030b9c2455b075083a39564920f325bb0bb046..c6ca11c3a63ef12cc4c1f5b02168a07e5c694c9a 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -70,6 +70,12 @@ var stage1Data = []ds.PropertyMap{
),
}
+var stage1Data3Enc = pmap("$key", key("Kind", 6), Next,
+ "Val", 5, 3, 2, Next,
+ "When", 946688461000000, Next,
+ "Extra", "waffle",
+)
+
var stage2Data = []ds.PropertyMap{
pmap("$key", key("Kind", 3, "Kind", 1), Next,
"Val", 2, 4, 28, Next,
@@ -85,6 +91,15 @@ var stage2Data = []ds.PropertyMap{
),
}
+var timeData = []ds.PropertyMap{
+ pmap("$key", key("Kind", 1), Next,
+ "Date", time.Date(2000, time.January, 1, 1, 1, 1, 1, time.UTC), Next,
+ ),
+ pmap("$key", key("Kind", 2), Next,
+ "Date", time.Date(2000, time.March, 1, 1, 1, 1, 1, time.UTC), Next,
+ ),
+}
+
var queryExecutionTests = []qExTest{
{"basic", []qExStage{
{
@@ -130,7 +145,9 @@ var queryExecutionTests = []qExTest{
indx("Kind!", "Bogus", "Extra", "-Val"),
},
expect: []qExpect{
- {q: nq("Kind"), get: stage1Data[:4]},
+ {q: nq("Kind"), get: []ds.PropertyMap{
+ stage1Data[0], stage1Data[1], stage1Data[2], stage1Data3Enc,
+ }},
{q: nq("Kind").Offset(2).Limit(1), get: []ds.PropertyMap{
stage1Data[2],
@@ -141,7 +158,7 @@ var queryExecutionTests = []qExTest{
{q: nq("Missing").Eq("Bogus", 3), get: []ds.PropertyMap{}},
{q: nq("Kind").Eq("Extra", "waffle"), get: []ds.PropertyMap{
- stage1Data[2], stage1Data[3],
+ stage1Data[2], stage1Data3Enc,
}},
// get ziggy with it
@@ -155,7 +172,7 @@ var queryExecutionTests = []qExTest{
{q: nq("Kind").Eq("Val", 2, 3), get: []ds.PropertyMap{
stage1Data[0],
- stage1Data[3],
+ stage1Data3Enc,
}},
// note the kind :)
@@ -205,11 +222,11 @@ var queryExecutionTests = []qExTest{
},
{q: nq("Kind").Gt("Val", 2).Lte("Val", 5), get: []ds.PropertyMap{
- stage1Data[0], stage1Data[3],
+ stage1Data[0], stage1Data3Enc,
}},
{q: nq("Kind").Gt("Val", 2).Lte("Val", 5).Order("-Val"), get: []ds.PropertyMap{
- stage1Data[3], stage1Data[0],
+ stage1Data3Enc, stage1Data[0],
}},
{q: nq("").Gt("__key__", key("Kind", 2)),
@@ -228,7 +245,7 @@ var queryExecutionTests = []qExTest{
// the index snapshot!
pmap("$key", key("Kind", 3, "__entity_group__", 1), Next,
"__version__", 5),
- stage1Data[3],
+ stage1Data3Enc,
pmap("$key", key("Kind", 6, "__entity_group__", 1), Next,
"__version__", 1),
pmap("$key", key("Unique", 1, "__entity_group__", 1), Next,
@@ -312,7 +329,7 @@ var queryExecutionTests = []qExTest{
// Original (complex) types are retained when getting the full value.
{q: nq("Kind").Order("When"), get: []ds.PropertyMap{
stage1Data[1],
- stage1Data[3],
+ stage1Data3Enc,
stage1Data[2],
}},
},
@@ -385,6 +402,28 @@ var queryExecutionTests = []qExTest{
},
},
}},
+ {"time range", []qExStage{
+ {
+ addIdxs: []*ds.IndexDefinition{
+ indx("Kind!", "Date"),
iannucci 2015/12/29 18:29:20 I think ! is shorthand for ancestor here, which yo
+ },
+ },
+ {
+ putEnts: timeData,
+ },
+ {
+ expect: []qExpect{
+ {
+ q: nq("Kind").Lte("Date", time.Date(2000, time.February, 1, 1, 1, 1, 1, time.UTC)),
+ get: []ds.PropertyMap{
+ pmap("$key", key("Kind", 1), Next,
+ "Date", 946688461000000, Next,
+ ),
+ },
+ },
+ },
+ },
+ }},
}
func TestQueryExecution(t *testing.T) {
@@ -468,7 +507,7 @@ func TestQueryExecution(t *testing.T) {
So(data.GetAll(expect.q, &rslt), ShouldBeNil)
So(len(rslt), ShouldEqual, len(expect.get))
for i, r := range rslt {
- So(r, ShouldResemble, expect.get[i])
+ So(r, ShouldResembleV, expect.get[i])
}
return nil
}, &ds.TransactionOptions{XG: true})

Powered by Google App Engine
This is Rietveld 408576698