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

Unified Diff: service/datastore/properties_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 | « service/datastore/properties.go ('k') | service/datastore/serialize/serialize.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/properties_test.go
diff --git a/service/datastore/properties_test.go b/service/datastore/properties_test.go
index 2dc8851fd3f3e8156feeb4b34a18d3b2e10e881c..0b797917fa818e1ecec548939cf6acb3d8f5d901 100644
--- a/service/datastore/properties_test.go
+++ b/service/datastore/properties_test.go
@@ -116,6 +116,23 @@ func TestProperties(t *testing.T) {
So(pv.IndexSetting(), ShouldEqual, ShouldIndex)
So(pv.Type().String(), ShouldEqual, "PTTime")
})
+ Convey("zero time", func() {
+ now := time.Time{}
+ So(now.IsZero(), ShouldBeTrue)
+
+ pv := Property{}
+ So(pv.SetValue(now, ShouldIndex), ShouldBeNil)
+ So(pv.Value(), ShouldResemble, now)
+ v, err := pv.Project(PTInt)
+ So(err, ShouldBeNil)
+ So(v, ShouldEqual, 0)
+
+ So(pv.SetValue(0, ShouldIndex), ShouldBeNil)
+ So(pv.Value(), ShouldEqual, 0)
+ v, err = pv.Project(PTTime)
+ So(err, ShouldBeNil)
+ So(v.(time.Time).IsZero(), ShouldBeTrue)
+ })
Convey("[]byte allows IndexSetting", func() {
pv := Property{}
So(pv.SetValue([]byte("hello"), ShouldIndex), ShouldBeNil)
@@ -124,6 +141,14 @@ func TestProperties(t *testing.T) {
So(pv.Type().String(), ShouldEqual, "PTBytes")
})
})
+
+ Convey("Comparison", func() {
+ Convey(`A []byte property should equal a string property with the same value.`, func() {
+ a := MkProperty([]byte("ohaithere"))
+ b := MkProperty("ohaithere")
+ So(a.Equal(&b), ShouldBeTrue)
+ })
+ })
})
}
« no previous file with comments | « service/datastore/properties.go ('k') | service/datastore/serialize/serialize.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698