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

Side by Side Diff: filter/count/count_test.go

Issue 1355783002: Refactor keys and queries in datastore service and implementation. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 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/count/rds.go » ('j') | filter/count/rds.go » ('J')
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 count 5 package count
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 So(ctr, ShouldNotBeNil) 45 So(ctr, ShouldNotBeNil)
46 46
47 ds := datastore.Get(c) 47 ds := datastore.Get(c)
48 vals := []datastore.PropertyMap{{ 48 vals := []datastore.PropertyMap{{
49 "Val": {datastore.MkProperty(100)}, 49 "Val": {datastore.MkProperty(100)},
50 "$key": {datastore.MkPropertyNI(ds.NewKey("Kind", "", 1, nil))}, 50 "$key": {datastore.MkPropertyNI(ds.NewKey("Kind", "", 1, nil))},
51 }} 51 }}
52 52
53 Convey("Calling a ds function should reflect in counter", func() { 53 Convey("Calling a ds function should reflect in counter", func() {
54 So(ds.PutMulti(vals), ShouldBeNil) 54 So(ds.PutMulti(vals), ShouldBeNil)
55 So(ctr.NewKey.Successes(), ShouldEqual, 1)
56 So(ctr.PutMulti.Successes(), ShouldEqual, 1) 55 So(ctr.PutMulti.Successes(), ShouldEqual, 1)
57 56
58 Convey("effects are cumulative", func() { 57 Convey("effects are cumulative", func() {
59 So(ds.PutMulti(vals), ShouldBeNil) 58 So(ds.PutMulti(vals), ShouldBeNil)
60 So(ctr.PutMulti.Successes(), ShouldEqual, 2) 59 So(ctr.PutMulti.Successes(), ShouldEqual, 2)
61 60
62 Convey("even within transactions", func() { 61 Convey("even within transactions", func() {
63 ds.RunInTransaction(func(c context.Conte xt) error { 62 ds.RunInTransaction(func(c context.Conte xt) error {
64 ds := datastore.Get(c) 63 ds := datastore.Get(c)
65 So(ds.PutMulti(append(vals, vals [0])), ShouldBeNil) 64 So(ds.PutMulti(append(vals, vals [0])), ShouldBeNil)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if err := ds.PutMulti(vals); err != nil { 146 if err := ds.PutMulti(vals); err != nil {
148 panic(err) 147 panic(err)
149 } 148 }
150 } 149 }
151 150
152 // Using the other function. 151 // Using the other function.
153 someCalledFunc(c) 152 someCalledFunc(c)
154 someCalledFunc(c) 153 someCalledFunc(c)
155 154
156 // Then we can see what happened! 155 // Then we can see what happened!
157 fmt.Printf("%s\n", counter.NewKey.String())
158 fmt.Printf("%d\n", counter.PutMulti.Successes()) 156 fmt.Printf("%d\n", counter.PutMulti.Successes())
159 // Output: 157 // Output:
160 // {Successes:2, Errors:0}
161 // 2 158 // 2
162 } 159 }
OLDNEW
« no previous file with comments | « no previous file | filter/count/rds.go » ('j') | filter/count/rds.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698