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

Side by Side Diff: impl/memory/datastore_test.go

Issue 1379673002: Add a NewDatastore helper function. (Closed) Base URL: https://github.com/luci/gae.git@fix_queries
Patch Set: Created 5 years, 2 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
« impl/memory/datastore.go ('K') | « impl/memory/datastore.go ('k') | no next file » | 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 "time"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 ds := dsS.Get(Use(context.Background())) 598 ds := dsS.Get(Use(context.Background()))
599 m := Model{ID: 1} 599 m := Model{ID: 1}
600 So(ds.Put(&m), ShouldBeNil) 600 So(ds.Put(&m), ShouldBeNil)
601 601
602 // Reset to something non zero to ensure zero is fetched. 602 // Reset to something non zero to ensure zero is fetched.
603 m.Time = time.Now().UTC() 603 m.Time = time.Now().UTC()
604 So(ds.Get(&m), ShouldBeNil) 604 So(ds.Get(&m), ShouldBeNil)
605 So(m.Time.IsZero(), ShouldBeTrue) 605 So(m.Time.IsZero(), ShouldBeTrue)
606 }) 606 })
607 } 607 }
608
609 func TestNewDatastore(t *testing.T) {
610 t.Parallel()
611
612 Convey("Can get and use a NewDatastore", t, func() {
613 ds, err := NewDatastore("aid", "ns")
614 So(err, ShouldBeNil)
615
616 k := ds.MakeKey("Something", 1)
617 So(k.AppID(), ShouldEqual, "aid")
618 So(k.Namespace(), ShouldEqual, "ns")
619
620 type Model struct {
621 ID int64 `gae:"$id"`
622 Value []int64
623 }
624 So(ds.Put(&Model{ID: 1, Value: []int64{20, 30}}), ShouldBeNil)
625
626 vals := []dsS.PropertyMap{}
627 So(ds.GetAll(dsS.NewQuery("Model").Project("Value"), &vals), Sho uldBeNil)
628 So(len(vals), ShouldEqual, 2)
629
630 So(vals[0]["Value"][0].Value(), ShouldEqual, 20)
631 So(vals[1]["Value"][0].Value(), ShouldEqual, 30)
632 })
633 }
OLDNEW
« impl/memory/datastore.go ('K') | « impl/memory/datastore.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698