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

Side by Side Diff: service/rawdatastore/context_test.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 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 | « service/rawdatastore/context.go ('k') | service/rawdatastore/datastore.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 rawdatastore
6
7 import (
8 "errors"
9 "testing"
10
11 . "github.com/smartystreets/goconvey/convey"
12 "golang.org/x/net/context"
13 )
14
15 type fakeService struct{ Interface }
16
17 type fakeFilt struct{ Interface }
18
19 func (fakeFilt) Count(Query) (int, error) {
20 return 0, errors.New("wow")
21 }
22
23 func TestServices(t *testing.T) {
24 t.Parallel()
25
26 Convey("Test service interfaces", t, func() {
27 c := context.Background()
28 Convey("without adding anything", func() {
29 So(Get(c), ShouldBeNil)
30 })
31
32 Convey("adding a basic implementation", func() {
33 c = Set(c, fakeService{})
34
35 Convey("lets you pull them back out", func() {
36 So(Get(c), ShouldResemble, fakeService{})
37 })
38
39 Convey("and lets you add filters", func() {
40 c = AddFilters(c, func(ic context.Context, rds I nterface) Interface {
41 return fakeFilt{rds}
42 })
43
44 _, err := Get(c).Count(nil)
45 So(err.Error(), ShouldEqual, "wow")
46 })
47 })
48 Convey("adding zero filters does nothing", func() {
49 So(AddFilters(c), ShouldEqual, c)
50 })
51 })
52 }
OLDNEW
« no previous file with comments | « service/rawdatastore/context.go ('k') | service/rawdatastore/datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698