-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy patherrors_test.go
More file actions
35 lines (26 loc) · 594 Bytes
/
errors_test.go
File metadata and controls
35 lines (26 loc) · 594 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package retry
import (
"errors"
"reflect"
"testing"
)
func TestError(t *testing.T) {
if internal.Error() != string(internal) {
t.Error("unexpected behavior")
}
if internal.Unwrap() != nil {
t.Error("unexpected behavior")
}
}
func TestUnwrap(t *testing.T) {
root := errors.New("root")
core := unwrap(cause{layer{root}})
if !reflect.DeepEqual(core, root) {
t.Error("unexpected behavior")
}
}
// helpers
type cause struct{ error }
func (cause cause) Cause() error { return cause.error }
type layer struct{ error }
func (layer layer) Unwrap() error { return layer.error }