OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package parallel |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 "testing" |
| 10 |
| 11 . "github.com/smartystreets/goconvey/convey" |
| 12 ) |
| 13 |
| 14 type otherMEType []error |
| 15 |
| 16 func (o otherMEType) Error() string { return "FAIL" } |
| 17 |
| 18 func TestMultiError(t *testing.T) { |
| 19 t.Parallel() |
| 20 |
| 21 Convey("MultiError works", t, func() { |
| 22 Convey("multiErrorFromErrors with errors works", func() { |
| 23 mec := make(chan error, 4) |
| 24 mec <- nil |
| 25 mec <- fmt.Errorf("first error") |
| 26 mec <- nil |
| 27 mec <- fmt.Errorf("what") |
| 28 close(mec) |
| 29 |
| 30 err := multiErrorFromErrors(mec) |
| 31 So(err.Error(), ShouldEqual, `first error (and 1 other e
rror)`) |
| 32 }) |
| 33 |
| 34 Convey("multiErrorFromErrors with nil works", func() { |
| 35 So(multiErrorFromErrors(nil), ShouldBeNil) |
| 36 |
| 37 c := make(chan error) |
| 38 close(c) |
| 39 So(multiErrorFromErrors(c), ShouldBeNil) |
| 40 |
| 41 c = make(chan error, 2) |
| 42 c <- nil |
| 43 c <- nil |
| 44 close(c) |
| 45 So(multiErrorFromErrors(c), ShouldBeNil) |
| 46 }) |
| 47 }) |
| 48 } |
OLD | NEW |