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

Unified Diff: impl/memory/datastore_test.go

Issue 1334043003: Use int64 to store time.Time internally in memory implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: test that IsZero Created 5 years, 3 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 | « no previous file | service/datastore/serialize/serialize.go » ('j') | service/datastore/serialize/serialize.go » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index 73a3dd50fbc9b59e36f0e0bb3ff5645a25e9adb9..1736e4bb5e1bc3254854ea3b2131a492408003e9 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -7,6 +7,7 @@ package memory
import (
"fmt"
"testing"
+ "time"
dsS "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/datastore/dskey"
@@ -530,3 +531,22 @@ func TestCompoundIndexes(t *testing.T) {
So(numItms(coll), ShouldEqual, 4)
})
}
+
+func TestDefaultTimeField(t *testing.T) {
iannucci 2015/09/15 02:35:06 this is fine, but probably add a link to this CL o
Vadim Sh. 2015/09/15 03:01:00 Done.
+ t.Parallel()
+
+ Convey("Default time.Time{} can be stored", t, func() {
+ type Model struct {
+ ID int64 `gae:"$id"`
+ Time time.Time
+ }
+ ds := dsS.Get(Use(context.Background()))
+ m := Model{ID: 1}
+ So(ds.Put(&m), ShouldBeNil)
+
+ // Reset to something non zero to ensure zero is fetched.
+ m.Time = time.Now()
+ So(ds.Get(&m), ShouldBeNil)
+ So(m.Time.IsZero(), ShouldBeTrue)
+ })
+}
« no previous file with comments | « no previous file | service/datastore/serialize/serialize.go » ('j') | service/datastore/serialize/serialize.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698