(t *testing.T)
| 203 | } |
| 204 | |
| 205 | func Test_deleteAsset_httpError(t *testing.T) { |
| 206 | reg := &httpmock.Registry{} |
| 207 | defer reg.Verify(t) |
| 208 | reg.Register( |
| 209 | func(req *http.Request) bool { |
| 210 | return req.Method == http.MethodDelete && |
| 211 | req.URL.EscapedPath() == "/repos/OWNER/REPO/releases/assets/1" && |
| 212 | req.URL.Host == "api.github.com" |
| 213 | }, |
| 214 | httpmock.StatusStringResponse(404, `{"message":"Not Found"}`), |
| 215 | ) |
| 216 | |
| 217 | httpClient := &http.Client{Transport: reg} |
| 218 | err := deleteAsset(httpClient, "example.com", safeurl.NewImmutableSafeURL("https://api.github.com/repos/OWNER/REPO/releases/assets/1")) |
| 219 | |
| 220 | var httpErr api.HTTPError |
| 221 | require.ErrorAs(t, err, &httpErr) |
| 222 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 223 | assert.Contains(t, err.Error(), "HTTP 404") |
| 224 | } |
nothing calls this directly
no test coverage detected