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

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

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint 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 unified diff | Download patch
« no previous file with comments | « filters/count/tq.go ('k') | filters/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 Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package featureBreaker 5 package featureBreaker
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "testing" 9 "testing"
10 10
11 "golang.org/x/net/context" 11 "golang.org/x/net/context"
12 12
13 » "github.com/luci/gae" 13 » "github.com/luci/gae/impl/memory"
14 » "github.com/luci/gae/memory" 14 » "github.com/luci/gae/service/rawdatastore"
15 15
16 . "github.com/smartystreets/goconvey/convey" 16 . "github.com/smartystreets/goconvey/convey"
17 ) 17 )
18 18
19 func TestBrokenFeatures(t *testing.T) { 19 func TestBrokenFeatures(t *testing.T) {
20 t.Parallel() 20 t.Parallel()
21 21
22 e := errors.New("default err") 22 e := errors.New("default err")
23 23
24 Convey("BrokenFeatures", t, func() { 24 Convey("BrokenFeatures", t, func() {
25 c := memory.Use(context.Background()) 25 c := memory.Use(context.Background())
26 26
27 Convey("Can break rds", func() { 27 Convey("Can break rds", func() {
28 Convey("without a default", func() { 28 Convey("without a default", func() {
29 c, bf := FilterRDS(c, nil) 29 c, bf := FilterRDS(c, nil)
30 » » » » rds := gae.GetRDS(c) 30 » » » » rds := rawdatastore.Get(c)
31 31
32 Convey("by specifying an error", func() { 32 Convey("by specifying an error", func() {
33 bf.BreakFeatures(e, "Get", "Put") 33 bf.BreakFeatures(e, "Get", "Put")
34 So(rds.Get(nil, nil), ShouldEqual, e) 34 So(rds.Get(nil, nil), ShouldEqual, e)
35 35
36 Convey("and you can unbreak them as well ", func() { 36 Convey("and you can unbreak them as well ", func() {
37 bf.UnbreakFeatures("Get") 37 bf.UnbreakFeatures("Get")
38 » » » » » » So(rds.Get(nil, nil), ShouldEqua l, gae.ErrDSInvalidKey) 38 » » » » » » So(rds.Get(nil, nil), ShouldEqua l, rawdatastore.ErrInvalidKey)
39 39
40 Convey("no broken features at al l is a shortcut", func() { 40 Convey("no broken features at al l is a shortcut", func() {
41 bf.UnbreakFeatures("Put" ) 41 bf.UnbreakFeatures("Put" )
42 » » » » » » » So(rds.Get(nil, nil), Sh ouldEqual, gae.ErrDSInvalidKey) 42 » » » » » » » So(rds.Get(nil, nil), Sh ouldEqual, rawdatastore.ErrInvalidKey)
43 }) 43 })
44 }) 44 })
45 }) 45 })
46 46
47 Convey("Not specifying an error gets you a gener ic error", func() { 47 Convey("Not specifying an error gets you a gener ic error", func() {
48 bf.BreakFeatures(nil, "Get") 48 bf.BreakFeatures(nil, "Get")
49 So(rds.Get(nil, nil).Error(), ShouldEqua l, `feature "Get" is broken`) 49 So(rds.Get(nil, nil).Error(), ShouldEqua l, `feature "Get" is broken`)
50 }) 50 })
51 }) 51 })
52 52
53 Convey("with a default", func() { 53 Convey("with a default", func() {
54 c, bf := FilterRDS(c, e) 54 c, bf := FilterRDS(c, e)
55 » » » » rds := gae.GetRDS(c) 55 » » » » rds := rawdatastore.Get(c)
56 bf.BreakFeatures(nil, "Get") 56 bf.BreakFeatures(nil, "Get")
57 So(rds.Get(nil, nil), ShouldEqual, e) 57 So(rds.Get(nil, nil), ShouldEqual, e)
58 }) 58 })
59 }) 59 })
60 }) 60 })
61 } 61 }
OLDNEW
« no previous file with comments | « filters/count/tq.go ('k') | filters/featureBreaker/gi.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698