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

Unified Diff: service/rawdatastore/context_test.go

Issue 1253263002: Make rawdatastore API safer for writing filters. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix comments Created 5 years, 5 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/rawdatastore/context.go ('k') | service/rawdatastore/datastore_key.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/rawdatastore/context_test.go
diff --git a/service/rawdatastore/context_test.go b/service/rawdatastore/context_test.go
index 5c4db01b705ba91afe113873b1bb94457330b13b..391e6f4cef4527da649d39e95a96d2ed903ea446 100644
--- a/service/rawdatastore/context_test.go
+++ b/service/rawdatastore/context_test.go
@@ -5,19 +5,24 @@
package rawdatastore
import (
- "errors"
"testing"
+ "github.com/luci/gae/service/info"
. "github.com/smartystreets/goconvey/convey"
"golang.org/x/net/context"
)
+type fakeInfo struct{ info.Interface }
+
+func (fakeInfo) GetNamespace() string { return "ns" }
+func (fakeInfo) AppID() string { return "aid" }
+
type fakeService struct{ Interface }
type fakeFilt struct{ Interface }
-func (fakeFilt) Count(Query) (int, error) {
- return 0, errors.New("wow")
+func (fakeFilt) NewKey(kind, stringID string, intID int64, parent Key) Key {
+ return NewKey("aid", "ns", kind, stringID, intID, parent)
}
func TestServices(t *testing.T) {
@@ -30,10 +35,10 @@ func TestServices(t *testing.T) {
})
Convey("adding a basic implementation", func() {
- c = Set(c, fakeService{})
+ c = Set(info.Set(c, fakeInfo{}), fakeService{})
Convey("lets you pull them back out", func() {
- So(Get(c), ShouldResemble, fakeService{})
+ So(Get(c), ShouldResemble, &checkFilter{fakeService{}, "aid", "ns"})
})
Convey("and lets you add filters", func() {
@@ -41,8 +46,8 @@ func TestServices(t *testing.T) {
return fakeFilt{rds}
})
- _, err := Get(c).Count(nil)
- So(err.Error(), ShouldEqual, "wow")
+ k := Get(c).NewKey("Kind", "", 1, nil)
+ So(KeysEqual(k, NewKey("aid", "ns", "Kind", "", 1, nil)), ShouldBeTrue)
})
})
Convey("adding zero filters does nothing", func() {
« no previous file with comments | « service/rawdatastore/context.go ('k') | service/rawdatastore/datastore_key.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698