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

Function Test_editRelease_httpError

pkg/cmd/release/edit/edit_test.go:485–505  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

483}
484
485func 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
507func Test_editRelease_bodyReadError(t *testing.T) {
508 readErr := errors.New("read: connection reset by peer")

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
StatusStringResponseFunction · 0.92
NewFunction · 0.92
editReleaseFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected