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 1550903002: impl/memory: Fix time serialization encoding. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Comments, tune-up. Created 4 years, 12 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.go ('k') | service/datastore/key.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 2a030b9c2455b075083a39564920f325bb0bb046..0f83959d90b42a99baad5a4d54fb1cb766ac5c05 100644
--- a/impl/memory/datastore_query_execution_test.go
+++ b/impl/memory/datastore_query_execution_test.go
@@ -10,11 +10,13 @@ import (
"testing"
"time"
+ "github.com/luci/gae/service/blobstore"
ds "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/info"
+ "golang.org/x/net/context"
+
. "github.com/luci/luci-go/common/testing/assertions"
. "github.com/smartystreets/goconvey/convey"
- "golang.org/x/net/context"
)
type qExpect struct {
@@ -85,6 +87,32 @@ var stage2Data = []ds.PropertyMap{
),
}
+var collapsedData = []ds.PropertyMap{
+ // PTTime
+ 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,
+ ),
+
+ // PTBlobKey
+ pmap("$key", key("Kind", 3), Next,
+ "Key", blobstore.Key("foo"), Next,
+ ),
+ pmap("$key", key("Kind", 4), Next,
+ "Key", blobstore.Key("qux"), Next,
+ ),
+
+ // PTBytes
+ pmap("$key", key("Kind", 5), Next,
+ "Val", []byte("ohai"), Next,
+ ),
+ pmap("$key", key("Kind", 6), Next,
+ "Val", []byte("uwutm8"), Next,
+ ),
+}
+
var queryExecutionTests = []qExTest{
{"basic", []qExStage{
{
@@ -385,6 +413,56 @@ var queryExecutionTests = []qExTest{
},
},
}},
+ {"collapsed types", []qExStage{
+ {
+ putEnts: collapsedData,
+ },
+ {
+ expect: []qExpect{
+ // PTTime
+ {
+ q: nq("Kind").Lte("Date", time.Date(2000, time.February, 1, 1, 1, 1, 1, time.UTC)),
+ get: []ds.PropertyMap{
+ collapsedData[0],
+ },
+ },
+ {
+ q: nq("Kind").Eq("Date", time.Date(2000, time.March, 1, 1, 1, 1, 1, time.UTC)),
+ get: []ds.PropertyMap{
+ collapsedData[1],
+ },
+ },
+
+ // PTBlobKey
+ {
+ q: nq("Kind").Lte("Key", blobstore.Key("foo")),
+ get: []ds.PropertyMap{
+ collapsedData[2],
+ },
+ },
+ {
+ q: nq("Kind").Eq("Key", blobstore.Key("qux")),
+ get: []ds.PropertyMap{
+ collapsedData[3],
+ },
+ },
+
+ // PTBytes
+ {
+ q: nq("Kind").Lte("Val", []byte("ohai")),
+ get: []ds.PropertyMap{
+ collapsedData[4],
+ },
+ },
+ {
+ q: nq("Kind").Eq("Val", []byte("uwutm8")),
+ get: []ds.PropertyMap{
+ collapsedData[5],
+ },
+ },
+ },
+ },
+ }},
}
func TestQueryExecution(t *testing.T) {
@@ -468,7 +546,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})
« no previous file with comments | « impl/memory/datastore_query.go ('k') | service/datastore/key.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698