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

Unified Diff: filter/featureBreaker/featurebreaker_test.go

Issue 1259593005: Add 'user friendly' datastore API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: more docs Created 5 years, 4 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 | « filter/count/rds.go ('k') | filter/featureBreaker/rds.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/featureBreaker/featurebreaker_test.go
diff --git a/filter/featureBreaker/featurebreaker_test.go b/filter/featureBreaker/featurebreaker_test.go
index 1ad8089117b611e1a348c704e4fbfeeb321bac25..35025baf0bd66a888db77a271a3246b398d57ee0 100644
--- a/filter/featureBreaker/featurebreaker_test.go
+++ b/filter/featureBreaker/featurebreaker_test.go
@@ -19,14 +19,6 @@ func TestBrokenFeatures(t *testing.T) {
e := errors.New("default err")
- cbe := func(expect string) func(datastore.PropertyMap, error) {
- return func(_ datastore.PropertyMap, err error) {
- So(err.Error(), ShouldContainSubstring, expect)
- }
- }
-
- cbn := func(datastore.PropertyMap, error) {}
-
Convey("BrokenFeatures", t, func() {
c := memory.Use(context.Background())
@@ -34,39 +26,40 @@ func TestBrokenFeatures(t *testing.T) {
Convey("without a default", func() {
c, bf := FilterRDS(c, nil)
ds := datastore.Get(c)
- keys := []datastore.Key{ds.NewKey("Wut", "", 1, nil)}
+ vals := []datastore.PropertyMap{{
+ "$key": {datastore.MkPropertyNI(ds.NewKey("Wut", "", 1, nil))},
+ }}
Convey("by specifying an error", func() {
bf.BreakFeatures(e, "GetMulti", "PutMulti")
- So(ds.GetMulti(keys, cbn), ShouldEqual, e)
+ So(ds.GetMulti(vals), ShouldEqual, e)
Convey("and you can unbreak them as well", func() {
bf.UnbreakFeatures("GetMulti")
- err := ds.GetMulti(keys, cbe(datastore.ErrNoSuchEntity.Error()))
- So(err, ShouldBeNil)
+ So(errors.SingleError(ds.GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
Convey("no broken features at all is a shortcut", func() {
bf.UnbreakFeatures("PutMulti")
- err := ds.GetMulti(keys, cbe(datastore.ErrNoSuchEntity.Error()))
- So(err, ShouldBeNil)
+ So(errors.SingleError(ds.GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
})
})
})
Convey("Not specifying an error gets you a generic error", func() {
bf.BreakFeatures(nil, "GetMulti")
- err := ds.GetMulti(keys, cbn)
- So(err.Error(), ShouldContainSubstring, `feature "GetMulti" is broken`)
+ So(ds.GetMulti(vals).Error(), ShouldContainSubstring, `feature "GetMulti" is broken`)
})
})
Convey("with a default", func() {
c, bf := FilterRDS(c, e)
ds := datastore.Get(c)
- keys := []datastore.Key{ds.NewKey("Wut", "", 1, nil)}
+ vals := []datastore.PropertyMap{{
+ "$key": {datastore.MkPropertyNI(ds.NewKey("Wut", "", 1, nil))},
+ }}
bf.BreakFeatures(nil, "GetMulti")
- So(ds.GetMulti(keys, cbn), ShouldEqual, e)
+ So(ds.GetMulti(vals), ShouldEqual, e)
})
})
})
« no previous file with comments | « filter/count/rds.go ('k') | filter/featureBreaker/rds.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698