-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtimeouterr_test.go
More file actions
42 lines (39 loc) · 724 Bytes
/
timeouterr_test.go
File metadata and controls
42 lines (39 loc) · 724 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
36
37
38
39
40
41
42
package rehttp
import (
"errors"
"net"
"testing"
"golang.org/x/net/context"
)
func Test_isTimeoutErr(t *testing.T) {
tests := []struct {
name string
err error
want bool
}{
{
name: "context timeouts should be retryable",
err: context.DeadlineExceeded,
want: true,
},
{
name: "net op errors are true",
err: &net.OpError{
Err: timeoutErr{},
},
want: true,
},
{
name: "non-network related errors should not be retryable",
err: errors.New("fake error"),
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := isTimeoutErr(tt.err); got != tt.want {
t.Errorf("isTimeoutErr() = %v, want %v", got, tt.want)
}
})
}
}