forked from luno/reflex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
61 lines (57 loc) · 1.17 KB
/
errors_test.go
File metadata and controls
61 lines (57 loc) · 1.17 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package reflex
import (
"context"
"testing"
"github.com/luno/fate"
"github.com/luno/jettison/errors"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/status"
)
func TestIsExpected(t *testing.T) {
tests := []struct {
Name string
Err error
Expected bool
}{
{
Name: "nil",
Err: nil,
Expected: false,
}, {
Name: "fate",
Err: fate.ErrTempt,
Expected: true,
}, {
Name: "context.Canceled",
Err: context.Canceled,
Expected: true,
}, {
Name: "context.DeadlineExceeded",
Err: context.DeadlineExceeded,
Expected: true,
}, {
Name: "ErrStopped",
Err: ErrStopped,
Expected: true,
}, {
Name: "Canceled status",
Err: status.FromContextError(context.Canceled).Err(),
Expected: true,
},
{
Name: "DeadlineExceeded status",
Err: status.FromContextError(context.DeadlineExceeded).Err(),
Expected: true,
},
{
Name: "not me",
Err: errors.New("not me"),
Expected: false,
},
}
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
require.Equal(t, test.Expected, IsExpected(test.Err))
})
}
}