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

Unified Diff: service/datastore/checkfilter_test.go

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: appease errcheck 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 | « service/datastore/checkfilter.go ('k') | service/datastore/context.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/checkfilter_test.go
diff --git a/service/datastore/checkfilter_test.go b/service/datastore/checkfilter_test.go
index 12e7911c0341547d6fbc1b22fb622b19dcbbccf2..8d4a8f7377a47af7f5ef53e59aec3f1e49d32d39 100644
--- a/service/datastore/checkfilter_test.go
+++ b/service/datastore/checkfilter_test.go
@@ -16,8 +16,6 @@ import (
type fakeRDS struct{ RawInterface }
-func (fakeRDS) NewQuery(string) Query { return &fakeQuery{} }
-
func TestCheckFilter(t *testing.T) {
t.Parallel()
@@ -36,67 +34,69 @@ func TestCheckFilter(t *testing.T) {
So(rds.RunInTransaction(nil, nil).Error(), ShouldContainSubstring, "is nil")
hit := false
So(func() {
- rds.RunInTransaction(func(context.Context) error {
+ So(rds.RunInTransaction(func(context.Context) error {
hit = true
return nil
- }, nil)
+ }, nil), ShouldBeNil)
}, ShouldPanic)
So(hit, ShouldBeFalse)
})
Convey("Run", func() {
So(rds.Run(nil, nil).Error(), ShouldContainSubstring, "query is nil")
- So(rds.Run(rds.NewQuery("sup"), nil).Error(), ShouldContainSubstring, "callback is nil")
+ fq, err := NewQuery("sup").Finalize()
+ So(err, ShouldBeNil)
+
+ So(rds.Run(fq, nil).Error(), ShouldContainSubstring, "callback is nil")
hit := false
So(func() {
- rds.Run(rds.NewQuery("sup"), func(Key, PropertyMap, CursorCB) bool {
+ So(rds.Run(fq, func(*Key, PropertyMap, CursorCB) bool {
hit = true
return true
- })
+ }), ShouldBeNil)
}, ShouldPanic)
So(hit, ShouldBeFalse)
})
Convey("GetMulti", func() {
So(rds.GetMulti(nil, nil, nil), ShouldBeNil)
- So(rds.GetMulti([]Key{mkKey("", "", "", "")}, nil, nil).Error(), ShouldContainSubstring, "is nil")
+ So(rds.GetMulti([]*Key{mkKey("", "", "", "")}, nil, nil).Error(), ShouldContainSubstring, "is nil")
// this is in the wrong aid/ns
- keys := []Key{mkKey("wut", "wrong", "Kind", 1)}
+ keys := []*Key{MakeKey("wut", "wrong", "Kind", 1)}
So(rds.GetMulti(keys, nil, func(pm PropertyMap, err error) {
So(pm, ShouldBeNil)
So(err, ShouldEqual, ErrInvalidKey)
}), ShouldBeNil)
- keys[0] = mkKey("s~aid", "ns", "Kind", 1)
+ keys[0] = mkKey("Kind", 1)
hit := false
So(func() {
- rds.GetMulti(keys, nil, func(pm PropertyMap, err error) {
+ So(rds.GetMulti(keys, nil, func(pm PropertyMap, err error) {
hit = true
- })
+ }), ShouldBeNil)
}, ShouldPanic)
So(hit, ShouldBeFalse)
})
Convey("PutMulti", func() {
- keys := []Key{}
+ keys := []*Key{}
vals := []PropertyMap{{}}
So(rds.PutMulti(keys, vals, nil).Error(),
ShouldContainSubstring, "mismatched keys/vals")
So(rds.PutMulti(nil, nil, nil), ShouldBeNil)
- badParent := mkKey("aid", "ns", "Wut", 0)
- keys = append(keys, mkKey("aid", "ns", "Kind", 0, badParent))
+ keys = append(keys, mkKey("aid", "ns", "Wut", 0, "Kind", 0))
So(rds.PutMulti(keys, vals, nil).Error(), ShouldContainSubstring, "callback is nil")
- So(rds.PutMulti(keys, vals, func(k Key, err error) {
+ So(rds.PutMulti(keys, vals, func(k *Key, err error) {
So(k, ShouldBeNil)
So(err, ShouldEqual, ErrInvalidKey)
}), ShouldBeNil)
- keys = []Key{mkKey("s~aid", "ns", "Kind", 0)}
+ keys = []*Key{mkKey("s~aid", "ns", "Kind", 0)}
vals = []PropertyMap{nil}
- So(rds.PutMulti(keys, vals, func(k Key, err error) {
+ So(rds.PutMulti(keys, vals, func(k *Key, err error) {
So(k, ShouldBeNil)
So(err.Error(), ShouldContainSubstring, "nil vals entry")
}), ShouldBeNil)
@@ -104,25 +104,25 @@ func TestCheckFilter(t *testing.T) {
vals = []PropertyMap{{}}
hit := false
So(func() {
- rds.PutMulti(keys, vals, func(k Key, err error) {
+ So(rds.PutMulti(keys, vals, func(k *Key, err error) {
hit = true
- })
+ }), ShouldBeNil)
}, ShouldPanic)
So(hit, ShouldBeFalse)
})
Convey("DeleteMulti", func() {
So(rds.DeleteMulti(nil, nil), ShouldBeNil)
- So(rds.DeleteMulti([]Key{mkKey("", "", "", "")}, nil).Error(), ShouldContainSubstring, "is nil")
- So(rds.DeleteMulti([]Key{mkKey("", "", "", "")}, func(err error) {
+ So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, nil).Error(), ShouldContainSubstring, "is nil")
+ So(rds.DeleteMulti([]*Key{mkKey("", "", "", "")}, func(err error) {
So(err, ShouldEqual, ErrInvalidKey)
}), ShouldBeNil)
hit := false
So(func() {
- rds.DeleteMulti([]Key{mkKey("s~aid", "ns", "Kind", 1)}, func(error) {
+ So(rds.DeleteMulti([]*Key{mkKey("s~aid", "ns", "Kind", 1)}, func(error) {
hit = true
- })
+ }), ShouldBeNil)
}, ShouldPanic)
So(hit, ShouldBeFalse)
})
« no previous file with comments | « service/datastore/checkfilter.go ('k') | service/datastore/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698