(t *testing.T)
| 245 | } |
| 246 | |
| 247 | func Test_deleteRelease_httpError(t *testing.T) { |
| 248 | reg := &httpmock.Registry{} |
| 249 | defer reg.Verify(t) |
| 250 | reg.Register( |
| 251 | func(req *http.Request) bool { |
| 252 | return req.Method == http.MethodDelete && |
| 253 | req.URL.EscapedPath() == "/repos/OWNER/REPO/releases/23456" && |
| 254 | req.URL.Host == "api.github.com" |
| 255 | }, |
| 256 | httpmock.StatusStringResponse(404, `{"message":"Not Found"}`), |
| 257 | ) |
| 258 | |
| 259 | httpClient := &http.Client{Transport: reg} |
| 260 | err := deleteRelease(httpClient, "example.com", safeurl.NewImmutableSafeURL("https://api.github.com/repos/OWNER/REPO/releases/23456")) |
| 261 | |
| 262 | var httpErr api.HTTPError |
| 263 | require.ErrorAs(t, err, &httpErr) |
| 264 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 265 | assert.Contains(t, err.Error(), "HTTP 404") |
| 266 | } |
| 267 | |
| 268 | func Test_deleteTag_httpError(t *testing.T) { |
| 269 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected