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

Unified 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, 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
« impl/memory/datastore.go ('K') | « impl/memory/datastore.go ('k') | no next file » | no next file with comments »
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 a95832ff71ef97de1210ffdf5edd29cbd0b97500..fda5b4969f3fe6da289d25ea1853de458003ba5b 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -605,3 +605,29 @@ func TestDefaultTimeField(t *testing.T) {
So(m.Time.IsZero(), ShouldBeTrue)
})
}
+
+func TestNewDatastore(t *testing.T) {
+ t.Parallel()
+
+ Convey("Can get and use a NewDatastore", t, func() {
+ ds, err := NewDatastore("aid", "ns")
+ So(err, ShouldBeNil)
+
+ k := ds.MakeKey("Something", 1)
+ So(k.AppID(), ShouldEqual, "aid")
+ So(k.Namespace(), ShouldEqual, "ns")
+
+ type Model struct {
+ ID int64 `gae:"$id"`
+ Value []int64
+ }
+ So(ds.Put(&Model{ID: 1, Value: []int64{20, 30}}), ShouldBeNil)
+
+ vals := []dsS.PropertyMap{}
+ So(ds.GetAll(dsS.NewQuery("Model").Project("Value"), &vals), ShouldBeNil)
+ So(len(vals), ShouldEqual, 2)
+
+ So(vals[0]["Value"][0].Value(), ShouldEqual, 20)
+ So(vals[1]["Value"][0].Value(), ShouldEqual, 30)
+ })
+}
« 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