(t *testing.T)
| 483 | } |
| 484 | |
| 485 | func Test_editRelease_httpError(t *testing.T) { |
| 486 | reg := &httpmock.Registry{} |
| 487 | defer reg.Verify(t) |
| 488 | reg.Register( |
| 489 | func(req *http.Request) bool { |
| 490 | return req.Method == http.MethodPatch && |
| 491 | req.URL.EscapedPath() == "/repos/OWNER/REPO/releases/12345" && |
| 492 | req.URL.Host == "api.github.com" |
| 493 | }, |
| 494 | httpmock.StatusStringResponse(404, `{"message":"Not Found"}`), |
| 495 | ) |
| 496 | |
| 497 | httpClient := &http.Client{Transport: reg} |
| 498 | release, err := editRelease(httpClient, ghrepo.New("OWNER", "REPO"), 12345, map[string]any{"tag_name": "v1.2.3"}) |
| 499 | |
| 500 | var httpErr api.HTTPError |
| 501 | require.ErrorAs(t, err, &httpErr) |
| 502 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 503 | assert.Contains(t, err.Error(), "HTTP 404") |
| 504 | assert.Nil(t, release) |
| 505 | } |
| 506 | |
| 507 | func Test_editRelease_bodyReadError(t *testing.T) { |
| 508 | readErr := errors.New("read: connection reset by peer") |
nothing calls this directly
no test coverage detected