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

Side by Side Diff: filter/featureBreaker/featurebreaker_test.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 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 unified diff | Download patch
« no previous file with comments | « filter/dscache/support.go ('k') | filter/featureBreaker/gi.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package featureBreaker 5 package featureBreaker
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 "github.com/luci/gae/impl/memory" 10 "github.com/luci/gae/impl/memory"
11 » "github.com/luci/gae/service/datastore" 11 » ds "github.com/luci/gae/service/datastore"
12 "github.com/luci/luci-go/common/errors" 12 "github.com/luci/luci-go/common/errors"
13
14 "golang.org/x/net/context"
15
13 . "github.com/smartystreets/goconvey/convey" 16 . "github.com/smartystreets/goconvey/convey"
14 "golang.org/x/net/context"
15 ) 17 )
16 18
17 func TestBrokenFeatures(t *testing.T) { 19 func TestBrokenFeatures(t *testing.T) {
18 t.Parallel() 20 t.Parallel()
19 21
20 e := errors.New("default err") 22 e := errors.New("default err")
21 23
22 Convey("BrokenFeatures", t, func() { 24 Convey("BrokenFeatures", t, func() {
23 c := memory.Use(context.Background()) 25 c := memory.Use(context.Background())
24 26
25 Convey("Can break ds", func() { 27 Convey("Can break ds", func() {
26 Convey("without a default", func() { 28 Convey("without a default", func() {
27 c, bf := FilterRDS(c, nil) 29 c, bf := FilterRDS(c, nil)
28 » » » » ds := datastore.Get(c) 30 » » » » vals := []ds.PropertyMap{{
29 » » » » vals := []datastore.PropertyMap{{ 31 » » » » » "$key": ds.MkPropertyNI(ds.NewKey(c, "Wu t", "", 1, nil)),
30 » » » » » "$key": datastore.MkPropertyNI(ds.NewKey ("Wut", "", 1, nil)),
31 }} 32 }}
32 33
33 Convey("by specifying an error", func() { 34 Convey("by specifying an error", func() {
34 bf.BreakFeatures(e, "GetMulti", "PutMult i") 35 bf.BreakFeatures(e, "GetMulti", "PutMult i")
35 » » » » » So(ds.GetMulti(vals), ShouldEqual, e) 36 » » » » » So(ds.Get(c, vals), ShouldEqual, e)
36 37
37 Convey("and you can unbreak them as well ", func() { 38 Convey("and you can unbreak them as well ", func() {
38 bf.UnbreakFeatures("GetMulti") 39 bf.UnbreakFeatures("GetMulti")
39 40
40 » » » » » » So(errors.SingleError(ds.GetMult i(vals)), ShouldEqual, datastore.ErrNoSuchEntity) 41 » » » » » » So(errors.SingleError(ds.Get(c, vals)), ShouldEqual, ds.ErrNoSuchEntity)
41 42
42 Convey("no broken features at al l is a shortcut", func() { 43 Convey("no broken features at al l is a shortcut", func() {
43 bf.UnbreakFeatures("PutM ulti") 44 bf.UnbreakFeatures("PutM ulti")
44 » » » » » » » So(errors.SingleError(ds .GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity) 45 » » » » » » » So(errors.SingleError(ds .Get(c, vals)), ShouldEqual, ds.ErrNoSuchEntity)
45 }) 46 })
46 }) 47 })
47 }) 48 })
48 49
49 Convey("Not specifying an error gets you a gener ic error", func() { 50 Convey("Not specifying an error gets you a gener ic error", func() {
50 bf.BreakFeatures(nil, "GetMulti") 51 bf.BreakFeatures(nil, "GetMulti")
51 » » » » » So(ds.GetMulti(vals).Error(), ShouldCont ainSubstring, `feature "GetMulti" is broken`) 52 » » » » » So(ds.Get(c, vals).Error(), ShouldContai nSubstring, `feature "GetMulti" is broken`)
52 }) 53 })
53 }) 54 })
54 55
55 Convey("with a default", func() { 56 Convey("with a default", func() {
56 c, bf := FilterRDS(c, e) 57 c, bf := FilterRDS(c, e)
57 » » » » ds := datastore.Get(c) 58 » » » » vals := []ds.PropertyMap{{
58 » » » » vals := []datastore.PropertyMap{{ 59 » » » » » "$key": ds.MkPropertyNI(ds.NewKey(c, "Wu t", "", 1, nil)),
59 » » » » » "$key": datastore.MkPropertyNI(ds.NewKey ("Wut", "", 1, nil)),
60 }} 60 }}
61 bf.BreakFeatures(nil, "GetMulti") 61 bf.BreakFeatures(nil, "GetMulti")
62 » » » » So(ds.GetMulti(vals), ShouldEqual, e) 62 » » » » So(ds.Get(c, vals), ShouldEqual, e)
63 }) 63 })
64 }) 64 })
65 }) 65 })
66 } 66 }
OLDNEW
« no previous file with comments | « filter/dscache/support.go ('k') | filter/featureBreaker/gi.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698