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

Unified Diff: service/datastore/checkfilter_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: service/datastore/checkfilter_test.go
diff --git a/service/datastore/checkfilter_test.go b/service/datastore/checkfilter_test.go
index 9f45b25a22147a2166c274dd60484c55ae130a9b..e2bf54dd18ab5245a6ebc7e1ea4254567bf859a1 100644
--- a/service/datastore/checkfilter_test.go
+++ b/service/datastore/checkfilter_test.go
@@ -10,8 +10,10 @@ import (
"testing"
"github.com/luci/gae/service/info"
- . "github.com/smartystreets/goconvey/convey"
+ "github.com/luci/luci-go/common/errors"
"golang.org/x/net/context"
+
+ . "github.com/smartystreets/goconvey/convey"
)
type fakeRDS struct{ RawInterface }
@@ -30,6 +32,28 @@ func TestCheckFilter(t *testing.T) {
rds := GetRaw(c) // has checkFilter
So(rds, ShouldNotBeNil)
+ Convey("AllocateIDs", func() {
+ Convey("Will return nil if no keys are supplied.", func() {
+ So(rds.AllocateIDs(nil), ShouldBeNil)
+ })
+
+ Convey("Will reject keys that are not PartialValid.", func() {
+ k := NewKey("s~aid", "ns", "", "", 0, nil) // No Kind.
+ So(k.PartialValid("s~aid", "ns"), ShouldBeFalse)
+
+ err := rds.AllocateIDs([]*Key{k})
+ So(err, ShouldResemble, errors.MultiError{ErrInvalidKey})
+ })
+
+ Convey("Will reject keys with non-homogenous entity types.", func() {
+ k0 := NewKey("s~aid", "ns", "OneKind", "", 0, nil)
+ k1 := NewKey("s~aid", "ns", "OtherKind", "", 0, nil)
+
+ err := rds.AllocateIDs([]*Key{k0, k1})
+ So(err, ShouldResemble, errors.MultiError{nil, ErrInvalidKey})
+ })
+ })
+
Convey("RunInTransaction", func() {
So(rds.RunInTransaction(nil, nil).Error(), ShouldContainSubstring, "is nil")
hit := false

Powered by Google App Engine
This is Rietveld 408576698