(t *testing.T)
| 1189 | } |
| 1190 | |
| 1191 | func TestRequestDo(t *testing.T) { |
| 1192 | testCases := []struct { |
| 1193 | Request *Request |
| 1194 | Err bool |
| 1195 | }{ |
| 1196 | { |
| 1197 | Request: &Request{err: errors.New("bail")}, |
| 1198 | Err: true, |
| 1199 | }, |
| 1200 | { |
| 1201 | Request: &Request{baseURL: &url.URL{}, pathPrefix: "%"}, |
| 1202 | Err: true, |
| 1203 | }, |
| 1204 | { |
| 1205 | Request: &Request{ |
| 1206 | client: clientFunc(func(req *http.Request) (*http.Response, error) { |
| 1207 | return nil, errors.New("err") |
| 1208 | }), |
| 1209 | baseURL: &url.URL{}, |
| 1210 | }, |
| 1211 | Err: true, |
| 1212 | }, |
| 1213 | } |
| 1214 | for i, testCase := range testCases { |
| 1215 | testCase.Request.backoffMgr = &NoBackoff{} |
| 1216 | body, err := testCase.Request.Do().Raw() |
| 1217 | hasErr := err != nil |
| 1218 | if hasErr != testCase.Err { |
| 1219 | t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err) |
| 1220 | } |
| 1221 | if hasErr && body != nil { |
| 1222 | t.Errorf("%d: body should be nil when error is returned", i) |
| 1223 | } |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | func TestDoRequestNewWay(t *testing.T) { |
| 1228 | reqBody := "request body" |
nothing calls this directly
no test coverage detected