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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/rawdatastore/context.go ('k') | service/rawdatastore/datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/rawdatastore/context_test.go
diff --git a/service/rawdatastore/context_test.go b/service/rawdatastore/context_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..5c4db01b705ba91afe113873b1bb94457330b13b
--- /dev/null
+++ b/service/rawdatastore/context_test.go
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package rawdatastore
+
+import (
+ "errors"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+ "golang.org/x/net/context"
+)
+
+type fakeService struct{ Interface }
+
+type fakeFilt struct{ Interface }
+
+func (fakeFilt) Count(Query) (int, error) {
+ return 0, errors.New("wow")
+}
+
+func TestServices(t *testing.T) {
+ t.Parallel()
+
+ Convey("Test service interfaces", t, func() {
+ c := context.Background()
+ Convey("without adding anything", func() {
+ So(Get(c), ShouldBeNil)
+ })
+
+ Convey("adding a basic implementation", func() {
+ c = Set(c, fakeService{})
+
+ Convey("lets you pull them back out", func() {
+ So(Get(c), ShouldResemble, fakeService{})
+ })
+
+ Convey("and lets you add filters", func() {
+ c = AddFilters(c, func(ic context.Context, rds Interface) Interface {
+ return fakeFilt{rds}
+ })
+
+ _, err := Get(c).Count(nil)
+ So(err.Error(), ShouldEqual, "wow")
+ })
+ })
+ Convey("adding zero filters does nothing", func() {
+ So(AddFilters(c), ShouldEqual, c)
+ })
+ })
+}
« 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