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

Unified Diff: service_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/taskqueue/types.go ('k') | taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service_test.go
diff --git a/service_test.go b/service_test.go
deleted file mode 100644
index 3d946e28b4344ba36a2fa2c28e208946ff153075..0000000000000000000000000000000000000000
--- a/service_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-// 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 gae
-
-import (
- "errors"
- "testing"
-
- . "github.com/smartystreets/goconvey/convey"
- "golang.org/x/net/context"
-)
-
-type fakeRDS struct{ RawDatastore }
-type fakeMC struct{ Memcache }
-type fakeTQ struct{ TaskQueue }
-type fakeGI struct{ GlobalInfo }
-
-type fakeFiltRDS struct{ RawDatastore }
-
-func (fakeFiltRDS) Count(DSQuery) (int, error) {
- return 0, errors.New("wow")
-}
-
-type fakeFiltTQ struct{ TaskQueue }
-
-func (fakeFiltTQ) Purge(string) error {
- return errors.New("wow")
-}
-
-type fakeFiltMC struct{ Memcache }
-
-func (fakeFiltMC) Flush() error {
- return errors.New("wow")
-}
-
-type fakeFiltGI struct{ GlobalInfo }
-
-func (fakeFiltGI) Namespace(string) (context.Context, error) {
- return nil, 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(GetRDS(c), ShouldBeNil)
- So(GetTQ(c), ShouldBeNil)
- So(GetMC(c), ShouldBeNil)
- So(GetGI(c), ShouldBeNil)
- })
-
- Convey("adding a basic implementation", func() {
- c = SetRDS(c, fakeRDS{})
- c = SetTQ(c, fakeTQ{})
- c = SetMC(c, fakeMC{})
- c = SetGI(c, fakeGI{})
-
- Convey("lets you pull them back out", func() {
- So(GetRDS(c), ShouldResemble, fakeRDS{})
- So(GetTQ(c), ShouldResemble, fakeTQ{})
- So(GetMC(c), ShouldResemble, fakeMC{})
- So(GetGI(c), ShouldResemble, fakeGI{})
- })
-
- Convey("and lets you add filters", func() {
- c = AddRDSFilters(c, func(ic context.Context, rds RawDatastore) RawDatastore {
- return fakeFiltRDS{rds}
- })
- c = AddTQFilters(c, func(ic context.Context, tq TaskQueue) TaskQueue {
- return fakeFiltTQ{tq}
- })
- c = AddMCFilters(c, func(ic context.Context, mc Memcache) Memcache {
- return fakeFiltMC{mc}
- })
- c = AddGIFilters(c, func(ic context.Context, gi GlobalInfo) GlobalInfo {
- return fakeFiltGI{gi}
- })
-
- _, err := GetRDS(c).Count(nil)
- So(err.Error(), ShouldEqual, "wow")
-
- So(GetTQ(c).Purge("").Error(), ShouldEqual, "wow")
-
- So(GetMC(c).Flush().Error(), ShouldEqual, "wow")
-
- _, err = GetGI(c).Namespace("")
- So(err.Error(), ShouldEqual, "wow")
- })
- })
- Convey("adding zero filters does nothing", func() {
- So(AddRDSFilters(c), ShouldEqual, c)
- So(AddTQFilters(c), ShouldEqual, c)
- So(AddMCFilters(c), ShouldEqual, c)
- So(AddGIFilters(c), ShouldEqual, c)
- })
- })
-}
« no previous file with comments | « service/taskqueue/types.go ('k') | taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698