OLD | NEW |
(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 } |
OLD | NEW |