(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestDoRequestError(t *testing.T) { |
| 326 | reg := &httpmock.Registry{} |
| 327 | defer reg.Verify(t) |
| 328 | client := newTestClient(reg) |
| 329 | |
| 330 | reg.Register(httpmock.MatchAny, httpmock.StatusJSONResponse(422, map[string]any{ |
| 331 | "message": "Validation Failed", |
| 332 | })) |
| 333 | |
| 334 | req, err := http.NewRequest(http.MethodPost, "https://uploads.github.com/assets", nil) |
| 335 | require.NoError(t, err) |
| 336 | |
| 337 | resp, err := client.DoRequest(req) |
| 338 | assert.Nil(t, resp) |
| 339 | |
| 340 | var httpErr HTTPError |
| 341 | require.ErrorAs(t, err, &httpErr) |
| 342 | assert.Equal(t, 422, httpErr.StatusCode) |
| 343 | assert.Equal(t, "Validation Failed", httpErr.Message) |
| 344 | } |
| 345 | |
| 346 | // The transport built by NewHTTPClient supplies default Accept, Content-Type and User-Agent |
| 347 | // headers. Per-request headers are only useful if they win against that real transport, so this |
nothing calls this directly
no test coverage detected