(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func TestAddRetryCondition(t *testing.T) { |
| 84 | attempt := 0 |
| 85 | resp, err := tc().R(). |
| 86 | SetRetryCount(3). |
| 87 | AddRetryCondition(func(resp *Response, err error) bool { |
| 88 | return err != nil |
| 89 | }). |
| 90 | AddRetryCondition(func(resp *Response, err error) bool { |
| 91 | return resp.StatusCode == http.StatusServiceUnavailable |
| 92 | }). |
| 93 | SetRetryHook(func(resp *Response, err error) { |
| 94 | attempt++ |
| 95 | }).Get("/too-many") |
| 96 | tests.AssertNoError(t, err) |
| 97 | tests.AssertEqual(t, 0, attempt) |
| 98 | tests.AssertEqual(t, 0, resp.Request.RetryAttempt) |
| 99 | |
| 100 | attempt = 0 |
| 101 | resp, err = tc(). |
| 102 | SetCommonRetryCount(3). |
| 103 | AddCommonRetryCondition(func(resp *Response, err error) bool { |
| 104 | return err != nil |
| 105 | }). |
| 106 | AddCommonRetryCondition(func(resp *Response, err error) bool { |
| 107 | return resp.StatusCode == http.StatusServiceUnavailable |
| 108 | }). |
| 109 | SetCommonRetryHook(func(resp *Response, err error) { |
| 110 | attempt++ |
| 111 | }).R().Get("/too-many") |
| 112 | tests.AssertNoError(t, err) |
| 113 | tests.AssertEqual(t, 0, attempt) |
| 114 | tests.AssertEqual(t, 0, resp.Request.RetryAttempt) |
| 115 | |
| 116 | } |
| 117 | |
| 118 | func TestRetryWithUnreplayableBody(t *testing.T) { |
| 119 | _, err := tc().R(). |
nothing calls this directly
no test coverage detected
searching dependent graphs…