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

Side by Side Diff: filter/count/count_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 | « no previous file | filter/dscache/dscache_test.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 count 5 package count
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 Convey("Test Count filter", t, func() { 49 Convey("Test Count filter", t, func() {
50 c, fb := featureBreaker.FilterRDS(memory.Use(context.Background( )), nil) 50 c, fb := featureBreaker.FilterRDS(memory.Use(context.Background( )), nil)
51 c, ctr := FilterRDS(c) 51 c, ctr := FilterRDS(c)
52 52
53 So(c, ShouldNotBeNil) 53 So(c, ShouldNotBeNil)
54 So(ctr, ShouldNotBeNil) 54 So(ctr, ShouldNotBeNil)
55 55
56 ds := datastore.Get(c) 56 ds := datastore.Get(c)
57 vals := []datastore.PropertyMap{{ 57 vals := []datastore.PropertyMap{{
58 » » » "Val": {datastore.MkProperty(100)}, 58 » » » "Val": datastore.MkProperty(100),
59 » » » "$key": {datastore.MkPropertyNI(ds.NewKey("Kind", "", 1, nil))}, 59 » » » "$key": datastore.MkPropertyNI(ds.NewKey("Kind", "", 1, nil)),
60 }} 60 }}
61 61
62 Convey("Calling a ds function should reflect in counter", func() { 62 Convey("Calling a ds function should reflect in counter", func() {
63 So(ds.PutMulti(vals), ShouldBeNil) 63 So(ds.PutMulti(vals), ShouldBeNil)
64 So(ctr.PutMulti.Successes(), ShouldEqual, 1) 64 So(ctr.PutMulti.Successes(), ShouldEqual, 1)
65 65
66 Convey("effects are cumulative", func() { 66 Convey("effects are cumulative", func() {
67 So(ds.PutMulti(vals), ShouldBeNil) 67 So(ds.PutMulti(vals), ShouldBeNil)
68 So(ctr.PutMulti.Successes(), ShouldEqual, 2) 68 So(ctr.PutMulti.Successes(), ShouldEqual, 2)
69 69
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 c := memory.Use(context.Background()) 201 c := memory.Use(context.Background())
202 202
203 // Apply the counter.FilterRDS 203 // Apply the counter.FilterRDS
204 c, counter := FilterRDS(c) 204 c, counter := FilterRDS(c)
205 205
206 // functions use ds from the context like normal... they don't need to k now 206 // functions use ds from the context like normal... they don't need to k now
207 // that there are any filters at all. 207 // that there are any filters at all.
208 someCalledFunc := func(c context.Context) { 208 someCalledFunc := func(c context.Context) {
209 ds := datastore.Get(c) 209 ds := datastore.Get(c)
210 vals := []datastore.PropertyMap{{ 210 vals := []datastore.PropertyMap{{
211 » » » "FieldName": {datastore.MkProperty(100)}, 211 » » » "FieldName": datastore.MkProperty(100),
212 » » » "$key": {datastore.MkProperty(ds.NewKey("Kind", "", 1, nil))}}, 212 » » » "$key": datastore.MkProperty(ds.NewKey("Kind", "", 1, nil))},
213 } 213 }
214 if err := ds.PutMulti(vals); err != nil { 214 if err := ds.PutMulti(vals); err != nil {
215 panic(err) 215 panic(err)
216 } 216 }
217 } 217 }
218 218
219 // Using the other function. 219 // Using the other function.
220 someCalledFunc(c) 220 someCalledFunc(c)
221 someCalledFunc(c) 221 someCalledFunc(c)
222 222
223 // Then we can see what happened! 223 // Then we can see what happened!
224 fmt.Printf("%d\n", counter.PutMulti.Successes()) 224 fmt.Printf("%d\n", counter.PutMulti.Successes())
225 // Output: 225 // Output:
226 // 2 226 // 2
227 } 227 }
OLDNEW
« no previous file with comments | « no previous file | filter/dscache/dscache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698