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

Unified Diff: common/sync/parallel/multierror_test.go

Issue 2958433002: [errors] Remove Fix(), move MultiErrorFromErrors(). (Closed)
Patch Set: Created 3 years, 6 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
Index: common/sync/parallel/multierror_test.go
diff --git a/common/errors/multierror_test.go b/common/sync/parallel/multierror_test.go
similarity index 50%
copy from common/errors/multierror_test.go
copy to common/sync/parallel/multierror_test.go
index 5d1363d03dcdaf806b2db67ed9520a1a219cec25..f5dd7276d4d325b8d3a718370040b8d79aa3f74c 100644
--- a/common/errors/multierror_test.go
+++ b/common/sync/parallel/multierror_test.go
@@ -2,13 +2,13 @@
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
-package errors
+package parallel
import (
- "errors"
"fmt"
"testing"
+ "github.com/luci/luci-go/common/errors"
. "github.com/smartystreets/goconvey/convey"
)
@@ -20,10 +20,6 @@ func TestMultiError(t *testing.T) {
t.Parallel()
Convey("MultiError works", t, func() {
- var me error = MultiError{fmt.Errorf("hello"), fmt.Errorf("bob")}
-
- So(me.Error(), ShouldEqual, `hello (and 1 other error)`)
-
Convey("MultiErrorFromErrors with errors works", func() {
mec := make(chan error, 4)
mec <- nil
@@ -52,59 +48,14 @@ func TestMultiError(t *testing.T) {
})
}
-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("SingleError passes through", t, func() {
- e := errors.New("unique")
- So(SingleError(e), ShouldEqual, e)
- })
-
- Convey("Test MultiError Conversion", t, func() {
- ome := otherMEType{errors.New("sup")}
- So(Fix(ome), ShouldHaveSameTypeAs, MultiError{})
- })
-
- Convey("Fix passes through", t, func() {
- e := errors.New("unique")
- So(Fix(e), ShouldEqual, e)
- })
-}
-
-func ExampleMultiError() {
+func ExampleMultiErrorFromErrors() {
errCh := make(chan error, 10)
errCh <- nil // nils are ignored
errCh <- fmt.Errorf("what")
close(errCh)
err := MultiErrorFromErrors(errCh)
- fmt.Printf("got: %s len=%d\n", err, len(err.(MultiError)))
+ fmt.Printf("got: %s len=%d\n", err, len(err.(errors.MultiError)))
errCh = make(chan error, 10)
errCh <- nil // and if the channel only has nils

Powered by Google App Engine
This is Rietveld 408576698