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

Unified Diff: go/src/infra/gae/libs/gae/brokenfeatures_test.go

Issue 1240573002: Reland: Refactor current GAE abstraction library to be free of the SDK* (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: expand coverage range to fit 32bit test expectations 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 | « go/src/infra/gae/libs/gae/brokenfeatures.go ('k') | go/src/infra/gae/libs/gae/context.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/gae/brokenfeatures_test.go
diff --git a/go/src/infra/gae/libs/wrapper/brokenfeatures_test.go b/go/src/infra/gae/libs/gae/brokenfeatures_test.go
similarity index 77%
rename from go/src/infra/gae/libs/wrapper/brokenfeatures_test.go
rename to go/src/infra/gae/libs/gae/brokenfeatures_test.go
index b7dd41b5a6a3976d4d8c70cd95f2203f10ca32d8..1f1b1bf003fe313f4f89826d1bd1c46536adb520 100644
--- a/go/src/infra/gae/libs/wrapper/brokenfeatures_test.go
+++ b/go/src/infra/gae/libs/gae/brokenfeatures_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package wrapper
+package gae
import (
"errors"
@@ -17,24 +17,25 @@ type foo struct {
BrokenFeatures
}
-func (f *foo) halp() error { // test the ability to call IsBroken from an internal helper
- return f.IsBroken()
+func (f *foo) RunIfNotBroken(fn func() error) error {
+ // can 'override' RunIfNotBroken
+ return f.BrokenFeatures.RunIfNotBroken(fn)
}
-func (f *foo) Foo() (string, error) {
- err := f.halp()
- if err != nil {
- return "", err
- }
- return "foo", nil
+func (f *foo) Foo() (ret string, err error) {
+ err = f.RunIfNotBroken(func() error {
+ ret = "foo"
+ return nil
+ })
+ return
}
-func (f *foo) Bar() (string, error) {
- err := f.halp()
- if err != nil {
- return "", err
- }
- return "bar", nil
+func (f *foo) Bar() (ret string, err error) {
+ err = f.RunIfNotBroken(func() error {
+ ret = "bar"
+ return nil
+ })
+ return
}
type override struct {
@@ -42,15 +43,15 @@ type override struct {
totallyRekt bool
}
-func (o *override) IsBroken() error {
+func (o *override) RunIfNotBroken(f func() error) error {
if o.totallyRekt {
return fmt.Errorf("totallyRekt")
}
- return o.BrokenFeatures.IsBroken()
+ return o.BrokenFeatures.RunIfNotBroken(f)
}
func (o *override) Foo() error {
- return o.IsBroken()
+ return o.RunIfNotBroken(func() error { return nil })
}
func TestBrokenFeatures(t *testing.T) {
@@ -118,7 +119,8 @@ func TestBrokenFeatures(t *testing.T) {
// break some feature so we're forced to crawl the stack.
bf.BreakFeatures(nil, "Nerds")
// should break because there's no exported functions on the stack.
- c.So(bf.IsBroken(), ShouldEqual, ErrBrokenFeaturesBroken)
+ err := bf.RunIfNotBroken(func() error { return nil })
+ c.So(err, ShouldEqual, ErrBrokenFeaturesBroken)
}()
wg.Wait()
})
« no previous file with comments | « go/src/infra/gae/libs/gae/brokenfeatures.go ('k') | go/src/infra/gae/libs/gae/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698