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

Unified Diff: go/src/infra/gae/libs/gae/upstream_errors_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/upstream_errors.go ('k') | go/src/infra/gae/libs/gae/upstream_types.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/upstream_errors_test.go
diff --git a/go/src/infra/gae/libs/gae/upstream_errors_test.go b/go/src/infra/gae/libs/gae/upstream_errors_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..a5a2e8276454482ce4eabd22ab326b6ecfafb037
--- /dev/null
+++ b/go/src/infra/gae/libs/gae/upstream_errors_test.go
@@ -0,0 +1,60 @@
+// 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"
+)
+
+type otherMEType []error
+
+func (o otherMEType) Error() string { return "FAIL" }
+
+func TestUpstreamErrors(t *testing.T) {
+ t.Parallel()
+
+ Convey("Test MultiError", t, func() {
+ Convey("nil", func() {
+ me := MultiError(nil)
+ So(me.Error(), ShouldEqual, "(0 errors)")
+ Convey("single", func() {
+ So(SingleError(error(me)), ShouldBeNil)
+ })
+ })
+ Convey("one", func() {
+ me := MultiError{errors.New("sup")}
+ So(me.Error(), ShouldEqual, "sup")
+ })
+ Convey("two", func() {
+ me := MultiError{errors.New("sup"), errors.New("what")}
+ So(me.Error(), ShouldEqual, "sup (and 1 other error)")
+ })
+ Convey("more", func() {
+ me := MultiError{errors.New("sup"), errors.New("what"), errors.New("nerds")}
+ So(me.Error(), ShouldEqual, "sup (and 2 other errors)")
+
+ Convey("single", func() {
+ So(SingleError(error(me)), ShouldResemble, errors.New("sup"))
+ })
+ })
+ Convey("convert", func() {
+ ome := otherMEType{errors.New("sup")}
+ So(FixError(ome), ShouldHaveSameTypeAs, MultiError{})
+ })
+ })
+
+ Convey("FixError passes through", t, func() {
+ e := errors.New("unique")
+ So(FixError(e), ShouldEqual, e)
+ })
+
+ Convey("SingleError passes through", t, func() {
+ e := errors.New("unique")
+ So(SingleError(e), ShouldEqual, e)
+ })
+}
« no previous file with comments | « go/src/infra/gae/libs/gae/upstream_errors.go ('k') | go/src/infra/gae/libs/gae/upstream_types.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698