-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
53 lines (50 loc) · 858 Bytes
/
error_test.go
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
package server
import (
"testing"
"github.com/pkg/errors"
)
func TestIsErrorNotFound(t *testing.T) {
type args struct {
err error
}
type want struct {
isNotFound bool
}
cases := map[string]struct {
args
want
}{
"ExpectTrue": {
args: args{
err: NewErrorNotFound("not-found"),
},
want: want{
isNotFound: true,
},
},
"ExpectWrappedTrue": {
args: args{
err: errors.Wrap(NewErrorNotFound("not-found"), "wrap"),
},
want: want{
isNotFound: true,
},
},
"ExpectFalse": {
args: args{
err: errors.New("some other error"),
},
want: want{
isNotFound: false,
},
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
res := IsErrorNotFound(tc.err)
if res != tc.want.isNotFound {
t.Errorf("Expected %v but got %v", tc.want.isNotFound, res)
}
})
}
}