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

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: Rebase, comments. Created 4 years, 6 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/everything_test.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 c08930000016ca0cc32643ce238b8cbb700e0abd..225e9f91b6670f3adc138e0b68a30724c042bd28 100644
--- a/impl/memory/datastore_test.go
+++ b/impl/memory/datastore_test.go
@@ -162,14 +162,25 @@ 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)
+ keys := ds.NewIncompleteKeys(100, "Foo", nil)
+ So(ds.AllocateIDs(keys), ShouldBeNil)
+ 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)
})
})
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/prod/everything_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698