(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestRetryWithModify(t *testing.T) { |
| 146 | tokens := []string{"badtoken1", "badtoken2", "goodtoken"} |
| 147 | tokenIndex := 0 |
| 148 | c := tc(). |
| 149 | SetCommonRetryCount(2). |
| 150 | SetCommonRetryHook(func(resp *Response, err error) { |
| 151 | tokenIndex++ |
| 152 | resp.Request.SetBearerAuthToken(tokens[tokenIndex]) |
| 153 | }).SetCommonRetryCondition(func(resp *Response, err error) bool { |
| 154 | return err != nil || resp.StatusCode == http.StatusUnauthorized |
| 155 | }) |
| 156 | |
| 157 | resp, err := c.R(). |
| 158 | SetBearerAuthToken(tokens[tokenIndex]). |
| 159 | Get("/protected") |
| 160 | assertSuccess(t, resp, err) |
| 161 | tests.AssertEqual(t, 2, resp.Request.RetryAttempt) |
| 162 | } |
| 163 | |
| 164 | func TestRetryFalse(t *testing.T) { |
| 165 | resp, err := tc().SetTimeout(2 * time.Second).R(). |
nothing calls this directly
no test coverage detected
searching dependent graphs…