MCPcopy Create free account
hub / github.com/cli/cli / Test_deleteRelease_httpError

Function Test_deleteRelease_httpError

pkg/cmd/release/delete/delete_test.go:247–266  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

245}
246
247func 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
268func Test_deleteTag_httpError(t *testing.T) {
269 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
StatusStringResponseFunction · 0.92
NewImmutableSafeURLFunction · 0.92
EqualMethod · 0.80
ContainsMethod · 0.80
deleteReleaseFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected