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

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

Issue 2958433002: [errors] Remove Fix(), move MultiErrorFromErrors(). (Closed)
Patch Set: keep it secret, keep it safe 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
« no previous file with comments | « common/errors/multierror_test.go ('k') | common/sync/parallel/workPool.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/sync/parallel/multierror_test.go
diff --git a/common/sync/parallel/multierror_test.go b/common/sync/parallel/multierror_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..6cb4b64f7dc023d895be58d86ddedbcc846ed528
--- /dev/null
+++ b/common/sync/parallel/multierror_test.go
@@ -0,0 +1,48 @@
+// Copyright 2015 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package parallel
+
+import (
+ "fmt"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+type otherMEType []error
+
+func (o otherMEType) Error() string { return "FAIL" }
+
+func TestMultiError(t *testing.T) {
+ t.Parallel()
+
+ Convey("MultiError works", t, func() {
+ Convey("multiErrorFromErrors with errors works", func() {
+ mec := make(chan error, 4)
+ mec <- nil
+ mec <- fmt.Errorf("first error")
+ mec <- nil
+ mec <- fmt.Errorf("what")
+ close(mec)
+
+ err := multiErrorFromErrors(mec)
+ So(err.Error(), ShouldEqual, `first error (and 1 other error)`)
+ })
+
+ Convey("multiErrorFromErrors with nil works", func() {
+ So(multiErrorFromErrors(nil), ShouldBeNil)
+
+ c := make(chan error)
+ close(c)
+ So(multiErrorFromErrors(c), ShouldBeNil)
+
+ c = make(chan error, 2)
+ c <- nil
+ c <- nil
+ close(c)
+ So(multiErrorFromErrors(c), ShouldBeNil)
+ })
+ })
+}
« no previous file with comments | « common/errors/multierror_test.go ('k') | common/sync/parallel/workPool.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698