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

Unified Diff: impl/memory/datastore_test.go

Issue 1357343002: Add missing AllocateIDs API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: add 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/prod/raw_datastore.go » ('j') | 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 f2572c3b547e1fae6f9a66bf8435b40b1b6df847..c604991159b633d75954698458516370256a3c7a 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -110,15 +110,14 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
Convey("ensure that group versions persist across deletes", func() {
So(ds.DeleteMulti(append(keys, k)), ShouldBeNil)
- // TODO(riannucci): replace with a Count query instead of this cast
- /*
- ents := ds.(*dsImpl).data.head.GetCollection("ents:")
- num, _ := ents.GetTotals()
- // /__entity_root_ids__,Foo
- // /Foo,1/__entity_group__,1
- // /Foo,1/__entity_group_ids__,1
- So(num, ShouldEqual, 3)
- */
+ ds.Testable().CatchupIndexes()
+
+ count := 0
+ So(ds.Run(dsS.NewQuery(""), func(_ *dsS.Key, _ dsS.CursorCB) bool {
+ count++
+ return true
+ }), ShouldBeNil)
+ So(count, ShouldEqual, 3)
So(testGetMeta(c, k), ShouldEqual, 22)
@@ -143,6 +142,17 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
})
})
+
+ Convey("allocating ids prevents their use", func() {
+ start, err := ds.AllocateIDs(ds.MakeKey("Foo", 0), 100)
+ So(err, ShouldBeNil)
+ So(start, ShouldEqual, 2)
+
+ f := &Foo{Val: 10}
+ So(ds.Put(f), ShouldBeNil)
+ k := ds.KeyForObj(f)
+ So(k.String(), ShouldEqual, "dev~app::/Foo,102")
+ })
})
Convey("implements DSTransactioner", func() {
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698