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

Side by Side 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: remove debug panic 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 unified diff | Download patch
« no previous file with comments | « no previous file | service/datastore/serialize/serialize.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time"
10 11
11 dsS "github.com/luci/gae/service/datastore" 12 dsS "github.com/luci/gae/service/datastore"
12 "github.com/luci/gae/service/datastore/dskey" 13 "github.com/luci/gae/service/datastore/dskey"
13 "github.com/luci/gae/service/datastore/serialize" 14 "github.com/luci/gae/service/datastore/serialize"
14 infoS "github.com/luci/gae/service/info" 15 infoS "github.com/luci/gae/service/info"
15 . "github.com/smartystreets/goconvey/convey" 16 . "github.com/smartystreets/goconvey/convey"
16 "golang.org/x/net/context" 17 "golang.org/x/net/context"
17 ) 18 )
18 19
19 func TestDatastoreKinder(t *testing.T) { 20 func TestDatastoreKinder(t *testing.T) {
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 524
524 idx.SortBy = append(idx.SortBy, dsS.IndexColumn{Property: "Field 1"}) 525 idx.SortBy = append(idx.SortBy, dsS.IndexColumn{Property: "Field 1"})
525 So(head.GetCollection(idxKey(idx)), ShouldBeNil) 526 So(head.GetCollection(idxKey(idx)), ShouldBeNil)
526 527
527 t.AddIndexes(&idx) 528 t.AddIndexes(&idx)
528 coll = head.GetCollection(idxKey(idx)) 529 coll = head.GetCollection(idxKey(idx))
529 So(coll, ShouldNotBeNil) 530 So(coll, ShouldNotBeNil)
530 So(numItms(coll), ShouldEqual, 4) 531 So(numItms(coll), ShouldEqual, 4)
531 }) 532 })
532 } 533 }
534
535 // High level test for regression in how zero time is stored,
536 // see https://codereview.chromium.org/1334043003/
537 func TestDefaultTimeField(t *testing.T) {
538 t.Parallel()
539
540 Convey("Default time.Time{} can be stored", t, func() {
541 type Model struct {
542 ID int64 `gae:"$id"`
543 Time time.Time
544 }
545 ds := dsS.Get(Use(context.Background()))
546 m := Model{ID: 1}
547 So(ds.Put(&m), ShouldBeNil)
548
549 // Reset to something non zero to ensure zero is fetched.
550 m.Time = time.Now().UTC()
551 So(ds.Get(&m), ShouldBeNil)
552 So(m.Time.IsZero(), ShouldBeTrue)
553 })
554 }
OLDNEW
« no previous file with comments | « no previous file | service/datastore/serialize/serialize.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698