OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package featureBreaker | |
6 | |
7 import ( | |
8 "errors" | |
9 "testing" | |
10 | |
11 "golang.org/x/net/context" | |
12 | |
13 "github.com/luci/gae/impl/memory" | |
14 "github.com/luci/gae/service/rawdatastore" | |
15 | |
16 . "github.com/smartystreets/goconvey/convey" | |
17 ) | |
18 | |
19 func TestBrokenFeatures(t *testing.T) { | |
20 t.Parallel() | |
21 | |
22 e := errors.New("default err") | |
23 | |
24 Convey("BrokenFeatures", t, func() { | |
25 c := memory.Use(context.Background()) | |
26 | |
27 Convey("Can break rds", func() { | |
28 Convey("without a default", func() { | |
29 c, bf := FilterRDS(c, nil) | |
30 rds := rawdatastore.Get(c) | |
31 | |
32 Convey("by specifying an error", func() { | |
33 bf.BreakFeatures(e, "Get", "Put") | |
34 So(rds.Get(nil, nil), ShouldEqual, e) | |
35 | |
36 Convey("and you can unbreak them as well
", func() { | |
37 bf.UnbreakFeatures("Get") | |
38 So(rds.Get(nil, nil), ShouldEqua
l, rawdatastore.ErrInvalidKey) | |
39 | |
40 Convey("no broken features at al
l is a shortcut", func() { | |
41 bf.UnbreakFeatures("Put"
) | |
42 So(rds.Get(nil, nil), Sh
ouldEqual, rawdatastore.ErrInvalidKey) | |
43 }) | |
44 }) | |
45 }) | |
46 | |
47 Convey("Not specifying an error gets you a gener
ic error", func() { | |
48 bf.BreakFeatures(nil, "Get") | |
49 So(rds.Get(nil, nil).Error(), ShouldEqua
l, `feature "Get" is broken`) | |
50 }) | |
51 }) | |
52 | |
53 Convey("with a default", func() { | |
54 c, bf := FilterRDS(c, e) | |
55 rds := rawdatastore.Get(c) | |
56 bf.BreakFeatures(nil, "Get") | |
57 So(rds.Get(nil, nil), ShouldEqual, e) | |
58 }) | |
59 }) | |
60 }) | |
61 } | |
OLD | NEW |