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

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

Issue 1525923002: Implement Mail service. (Closed) Base URL: https://github.com/luci/gae.git@filter_user
Patch Set: tests and words Created 5 years 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/mail.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 count 5 package count
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 10
11 "github.com/luci/gae/filter/featureBreaker" 11 "github.com/luci/gae/filter/featureBreaker"
12 "github.com/luci/gae/impl/memory" 12 "github.com/luci/gae/impl/memory"
13 "github.com/luci/gae/service/datastore" 13 "github.com/luci/gae/service/datastore"
14 "github.com/luci/gae/service/info" 14 "github.com/luci/gae/service/info"
15 "github.com/luci/gae/service/mail"
15 "github.com/luci/gae/service/memcache" 16 "github.com/luci/gae/service/memcache"
16 "github.com/luci/gae/service/taskqueue" 17 "github.com/luci/gae/service/taskqueue"
17 "github.com/luci/gae/service/user" 18 "github.com/luci/gae/service/user"
18 . "github.com/luci/luci-go/common/testing/assertions" 19 . "github.com/luci/luci-go/common/testing/assertions"
19 . "github.com/smartystreets/goconvey/convey" 20 . "github.com/smartystreets/goconvey/convey"
20 "golang.org/x/net/context" 21 "golang.org/x/net/context"
21 ) 22 )
22 23
23 func shouldHaveSuccessesAndErrors(actual interface{}, expected ...interface{}) s tring { 24 func shouldHaveSuccessesAndErrors(actual interface{}, expected ...interface{}) s tring {
24 a := actual.(Entry) 25 a := actual.(Entry)
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 u := user.Get(c) 152 u := user.Get(c)
152 153
153 _, err := u.CurrentOAuth("foo") 154 _, err := u.CurrentOAuth("foo")
154 die(err) 155 die(err)
155 fb.BreakFeatures(nil, "CurrentOAuth") 156 fb.BreakFeatures(nil, "CurrentOAuth")
156 _, err = u.CurrentOAuth("foo") 157 _, err = u.CurrentOAuth("foo")
157 So(err, ShouldErrLike, `"CurrentOAuth" is broken`) 158 So(err, ShouldErrLike, `"CurrentOAuth" is broken`)
158 159
159 So(ctr.CurrentOAuth, shouldHaveSuccessesAndErrors, 1, 1) 160 So(ctr.CurrentOAuth, shouldHaveSuccessesAndErrors, 1, 1)
160 }) 161 })
162
163 Convey("works for mail", t, func() {
164 c, fb := featureBreaker.FilterMail(memory.Use(context.Background ()), nil)
165 c, ctr := FilterMail(c)
166 So(c, ShouldNotBeNil)
167 So(ctr, ShouldNotBeNil)
168
169 m := mail.Get(c)
170
171 err := m.Send(&mail.Message{
172 Sender: "admin@example.com",
173 To: []string{"coolDood@example.com"},
174 Body: "hi",
175 })
176 die(err)
177
178 fb.BreakFeatures(nil, "Send")
179 err = m.Send(&mail.Message{
180 Sender: "admin@example.com",
181 To: []string{"coolDood@example.com"},
182 Body: "hi",
183 })
184 So(err, ShouldErrLike, `"Send" is broken`)
185
186 So(ctr.Send, shouldHaveSuccessesAndErrors, 1, 1)
187 })
161 } 188 }
162 189
163 func ExampleFilterRDS() { 190 func ExampleFilterRDS() {
164 // Set up your context using a base service implementation (memory or pr od) 191 // Set up your context using a base service implementation (memory or pr od)
165 c := memory.Use(context.Background()) 192 c := memory.Use(context.Background())
166 193
167 // Apply the counter.FilterRDS 194 // Apply the counter.FilterRDS
168 c, counter := FilterRDS(c) 195 c, counter := FilterRDS(c)
169 196
170 // functions use ds from the context like normal... they don't need to k now 197 // functions use ds from the context like normal... they don't need to k now
(...skipping 11 matching lines...) Expand all
182 209
183 // Using the other function. 210 // Using the other function.
184 someCalledFunc(c) 211 someCalledFunc(c)
185 someCalledFunc(c) 212 someCalledFunc(c)
186 213
187 // Then we can see what happened! 214 // Then we can see what happened!
188 fmt.Printf("%d\n", counter.PutMulti.Successes()) 215 fmt.Printf("%d\n", counter.PutMulti.Successes())
189 // Output: 216 // Output:
190 // 2 217 // 2
191 } 218 }
OLDNEW
« no previous file with comments | « no previous file | filter/count/mail.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698