OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package errors | 5 package errors |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "testing" | 10 "testing" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 errors.New("other error"), | 59 errors.New("other error"), |
60 } { | 60 } { |
61 Convey(fmt.Sprintf(`Registers false for %T %v`, err, err
), func() { | 61 Convey(fmt.Sprintf(`Registers false for %T %v`, err, err
), func() { |
62 So(Any(err, filter), ShouldBeFalse) | 62 So(Any(err, filter), ShouldBeFalse) |
63 }) | 63 }) |
64 } | 64 } |
65 | 65 |
66 for _, err := range []error{ | 66 for _, err := range []error{ |
67 testErr, | 67 testErr, |
68 MultiError{errors.New("other error"), MultiError{testErr
, nil}}, | 68 MultiError{errors.New("other error"), MultiError{testErr
, nil}}, |
69 » » » Annotate(testErr).Reason("error test").Err(), | 69 » » » Annotate(testErr, "error test").Err(), |
70 } { | 70 } { |
71 Convey(fmt.Sprintf(`Registers true for %T %v`, err, err)
, func() { | 71 Convey(fmt.Sprintf(`Registers true for %T %v`, err, err)
, func() { |
72 So(Any(err, filter), ShouldBeTrue) | 72 So(Any(err, filter), ShouldBeTrue) |
73 }) | 73 }) |
74 } | 74 } |
75 }) | 75 }) |
76 } | 76 } |
77 | |
78 func TestContains(t *testing.T) { | |
79 t.Parallel() | |
80 | |
81 Convey(`Testing the Contains function for a sentinel error`, t, func() { | |
82 sentinel := errors.New("test error") | |
83 | |
84 for _, err := range []error{ | |
85 nil, | |
86 errors.New("foo"), | |
87 errors.New("test error"), | |
88 } { | |
89 Convey(fmt.Sprintf(`Registers false for %T %v`, err, err
), func() { | |
90 So(Contains(err, sentinel), ShouldBeFalse) | |
91 }) | |
92 } | |
93 | |
94 for _, err := range []error{ | |
95 sentinel, | |
96 MultiError{errors.New("other error"), MultiError{sentine
l, nil}}, | |
97 } { | |
98 Convey(fmt.Sprintf(`Registers true for %T %v`, err, err)
, func() { | |
99 So(Contains(err, sentinel), ShouldBeTrue) | |
100 }) | |
101 } | |
102 }) | |
103 } | |
OLD | NEW |