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

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

Issue 2342063003: Differentiate between single- and multi- props. (Closed)
Patch Set: Slice is now always a clone. This is marginally worse performance, but a much safer UI. 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/dscache_test.go ('k') | filter/txnBuf/query_merger.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 "github.com/luci/gae/service/datastore"
12 "github.com/luci/luci-go/common/errors" 12 "github.com/luci/luci-go/common/errors"
13 . "github.com/smartystreets/goconvey/convey" 13 . "github.com/smartystreets/goconvey/convey"
14 "golang.org/x/net/context" 14 "golang.org/x/net/context"
15 ) 15 )
16 16
17 func TestBrokenFeatures(t *testing.T) { 17 func TestBrokenFeatures(t *testing.T) {
18 t.Parallel() 18 t.Parallel()
19 19
20 e := errors.New("default err") 20 e := errors.New("default err")
21 21
22 Convey("BrokenFeatures", t, func() { 22 Convey("BrokenFeatures", t, func() {
23 c := memory.Use(context.Background()) 23 c := memory.Use(context.Background())
24 24
25 Convey("Can break ds", func() { 25 Convey("Can break ds", func() {
26 Convey("without a default", func() { 26 Convey("without a default", func() {
27 c, bf := FilterRDS(c, nil) 27 c, bf := FilterRDS(c, nil)
28 ds := datastore.Get(c) 28 ds := datastore.Get(c)
29 vals := []datastore.PropertyMap{{ 29 vals := []datastore.PropertyMap{{
30 » » » » » "$key": {datastore.MkPropertyNI(ds.NewKe y("Wut", "", 1, nil))}, 30 » » » » » "$key": datastore.MkPropertyNI(ds.NewKey ("Wut", "", 1, nil)),
31 }} 31 }}
32 32
33 Convey("by specifying an error", func() { 33 Convey("by specifying an error", func() {
34 bf.BreakFeatures(e, "GetMulti", "PutMult i") 34 bf.BreakFeatures(e, "GetMulti", "PutMult i")
35 So(ds.GetMulti(vals), ShouldEqual, e) 35 So(ds.GetMulti(vals), ShouldEqual, e)
36 36
37 Convey("and you can unbreak them as well ", func() { 37 Convey("and you can unbreak them as well ", func() {
38 bf.UnbreakFeatures("GetMulti") 38 bf.UnbreakFeatures("GetMulti")
39 39
40 So(errors.SingleError(ds.GetMult i(vals)), ShouldEqual, datastore.ErrNoSuchEntity) 40 So(errors.SingleError(ds.GetMult i(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
41 41
42 Convey("no broken features at al l is a shortcut", func() { 42 Convey("no broken features at al l is a shortcut", func() {
43 bf.UnbreakFeatures("PutM ulti") 43 bf.UnbreakFeatures("PutM ulti")
44 So(errors.SingleError(ds .GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity) 44 So(errors.SingleError(ds .GetMulti(vals)), ShouldEqual, datastore.ErrNoSuchEntity)
45 }) 45 })
46 }) 46 })
47 }) 47 })
48 48
49 Convey("Not specifying an error gets you a gener ic error", func() { 49 Convey("Not specifying an error gets you a gener ic error", func() {
50 bf.BreakFeatures(nil, "GetMulti") 50 bf.BreakFeatures(nil, "GetMulti")
51 So(ds.GetMulti(vals).Error(), ShouldCont ainSubstring, `feature "GetMulti" is broken`) 51 So(ds.GetMulti(vals).Error(), ShouldCont ainSubstring, `feature "GetMulti" is broken`)
52 }) 52 })
53 }) 53 })
54 54
55 Convey("with a default", func() { 55 Convey("with a default", func() {
56 c, bf := FilterRDS(c, e) 56 c, bf := FilterRDS(c, e)
57 ds := datastore.Get(c) 57 ds := datastore.Get(c)
58 vals := []datastore.PropertyMap{{ 58 vals := []datastore.PropertyMap{{
59 » » » » » "$key": {datastore.MkPropertyNI(ds.NewKe y("Wut", "", 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.GetMulti(vals), ShouldEqual, e)
63 }) 63 })
64 }) 64 })
65 }) 65 })
66 } 66 }
OLDNEW
« no previous file with comments | « filter/dscache/dscache_test.go ('k') | filter/txnBuf/query_merger.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698