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

Unified Diff: impl/memory/datastore_test.go

Issue 2007123002: datastore: Update AllocateIDs to take keys. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 7 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
Index: impl/memory/datastore_test.go
diff --git a/impl/memory/datastore_test.go b/impl/memory/datastore_test.go
index 3b9f91e212dfc2f75d09512216539fc0785e295e..2480aeef10ff52166d6933821a3437bf0a03ec0e 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -162,14 +162,26 @@ func TestDatastoreSingleReadWriter(t *testing.T) {
})
Convey("allocating ids prevents their use", func() {
- start, err := ds.AllocateIDs(ds.MakeKey("Foo", 0), 100)
+ keys := ds.NewIncompleteKeys(100, "Foo", nil)
+ keys, err := ds.AllocateIDs(keys...)
So(err, ShouldBeNil)
- So(start, ShouldEqual, 2)
+ So(len(keys), ShouldEqual, 100)
+ // Assert that none of our keys share the same ID.
+ ids := make(map[int64]struct{})
+ for _, k := range keys {
+ ids[k.IntID()] = struct{}{}
+ }
+ So(len(ids), ShouldEqual, len(keys))
+
+ // Put a new object and ensure that it is allocated an unused ID.
f := &Foo{Val: 10}
So(ds.Put(f), ShouldBeNil)
k := ds.KeyForObj(f)
So(k.String(), ShouldEqual, "dev~app::/Foo,102")
+
+ _, ok := ids[k.IntID()]
+ So(ok, ShouldBeFalse)
})
})

Powered by Google App Engine
This is Rietveld 408576698