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 errors | |
6 | |
7 import ( | |
8 "errors" | |
9 "testing" | |
10 | |
11 . "github.com/smartystreets/goconvey/convey" | |
12 ) | |
13 | |
14 func TestTransientError(t *testing.T) { | |
15 t.Parallel() | |
16 | |
17 Convey(`A nil error`, t, func() { | |
18 err := error(nil) | |
19 | |
20 Convey(`Is not transient.`, func() { | |
21 So(IsTransient(err), ShouldBeFalse) | |
22 }) | |
23 | |
24 Convey(`Returns nil when wrapped with a transient error.`, func(
) { | |
25 So(WrapTransient(err), ShouldBeNil) | |
26 }) | |
27 }) | |
28 | |
29 Convey(`An error`, t, func() { | |
30 err := errors.New("test error") | |
31 | |
32 Convey(`Is not transient.`, func() { | |
33 So(IsTransient(err), ShouldBeFalse) | |
34 }) | |
35 Convey(`When wrapped with a transient error`, func() { | |
36 terr := WrapTransient(err) | |
37 Convey(`Has the same error string.`, func() { | |
38 So(terr.Error(), ShouldEqual, "test error") | |
39 }) | |
40 Convey(`Is transient.`, func() { | |
41 So(IsTransient(terr), ShouldBeTrue) | |
42 }) | |
43 }) | |
44 | |
45 Convey(`A MultiError with a transient sub-error is transient.`,
func() { | |
46 So(IsTransient(MultiError{nil, WrapTransient(err), err})
, ShouldBeTrue) | |
47 }) | |
48 }) | |
49 } | |
OLD | NEW |