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 |