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

Unified Diff: service/datastore/serialize/serialize_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: service/datastore/serialize/serialize_test.go
diff --git a/service/datastore/serialize/serialize_test.go b/service/datastore/serialize/serialize_test.go
index 3dd7127c1c039f2853f434ac9309543fbb1fe42a..3f51690df85a2e6e598ab80161d00027bde633db 100644
--- a/service/datastore/serialize/serialize_test.go
+++ b/service/datastore/serialize/serialize_test.go
@@ -30,6 +30,7 @@ var (
type dspmapTC struct {
name string
props ds.PropertyMap
+ exp ds.PropertyMap
}
var mkKey = ds.MakeKey
@@ -52,45 +53,53 @@ func ShouldEqualKey(actual interface{}, expected ...interface{}) string {
func TestPropertyMapSerialization(t *testing.T) {
t.Parallel()
+ now := time.Now().UTC()
tests := []dspmapTC{
{
- "basic",
- ds.PropertyMap{
+ name: "basic",
+ props: ds.PropertyMap{
"R": {mp(false), mp(2.1), mpNI(3)},
"S": {mp("hello"), mp("world")},
},
},
{
- "keys",
- ds.PropertyMap{
+ name: "keys",
+ props: ds.PropertyMap{
"DS": {mp(mkKey("appy", "ns", "Foo", 7)), mp(mkKey("other", "", "Yot", "wheeep"))},
"blobstore": {mp(blobstore.Key("sup")), mp(blobstore.Key("nerds"))},
},
},
{
- "geo",
- ds.PropertyMap{
+ name: "geo",
+ props: ds.PropertyMap{
"G": {mp(ds.GeoPoint{Lat: 1, Lng: 2})},
},
},
{
- "data",
- ds.PropertyMap{
+ name: "data",
+ props: ds.PropertyMap{
"S": {mp("sup"), mp("fool"), mp("nerd")},
"D.Foo.Nerd": {mp([]byte("sup")), mp([]byte("fool"))},
},
},
{
- "time",
- ds.PropertyMap{
+ name: "time",
+ props: ds.PropertyMap{
"T": {
- mp(time.Now().UTC()),
- mp(time.Now().Add(time.Second).UTC())},
+ mp(now),
+ mp(now),
+ },
+ },
+ exp: ds.PropertyMap{
+ "T": {
+ mp(timeToInt(now)),
+ mp(timeToInt(now)),
+ },
},
},
{
- "empty vals",
- ds.PropertyMap{
+ name: "empty vals",
+ props: ds.PropertyMap{
"T": {mp(true), mp(true)},
"F": {mp(false), mp(false)},
"N": {mp(nil), mp(nil)},
@@ -107,7 +116,12 @@ func TestPropertyMapSerialization(t *testing.T) {
data := ToBytesWithContext(tc.props)
dec, err := ReadPropertyMap(mkBuf(data), WithContext, "", "")
So(err, ShouldBeNil)
- So(dec, ShouldResemble, tc.props)
+
+ exp := tc.exp
+ if exp == nil {
+ exp = tc.props
+ }
+ So(dec, ShouldResemble, exp)
})
}
})
« service/datastore/serialize/serialize.go ('K') | « service/datastore/serialize/serialize.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698