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

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: 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 unified diff | Download patch
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 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.
536 t.Parallel()
537
538 Convey("Default time.Time{} can be stored", t, func() {
539 type Model struct {
540 ID int64 `gae:"$id"`
541 Time time.Time
542 }
543 ds := dsS.Get(Use(context.Background()))
544 m := Model{ID: 1}
545 So(ds.Put(&m), ShouldBeNil)
546
547 // Reset to something non zero to ensure zero is fetched.
548 m.Time = time.Now()
549 So(ds.Get(&m), ShouldBeNil)
550 So(m.Time.IsZero(), ShouldBeTrue)
551 })
552 }
OLDNEW
« 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