MCPcopy Index your code
hub / github.com/imroc/req / TestRetryWithModify

Function TestRetryWithModify

retry_test.go:145–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func 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
164func TestRetryFalse(t *testing.T) {
165 resp, err := tc().SetTimeout(2 * time.Second).R().

Callers

nothing calls this directly

Calls 9

AssertEqualFunction · 0.92
tcFunction · 0.85
assertSuccessFunction · 0.85
SetCommonRetryHookMethod · 0.80
SetCommonRetryCountMethod · 0.80
SetBearerAuthTokenMethod · 0.80
RMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…