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

Function TestDeleteDeployKeyHTTPError

pkg/cmd/repo/deploy-key/delete/delete_test.go:44–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestDeleteDeployKeyHTTPError(t *testing.T) {
45 reg := &httpmock.Registry{}
46 defer reg.Verify(t)
47
48 reg.Register(
49 httpmock.REST("DELETE", "repos/OWNER/REPO/keys/1234"),
50 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
51 )
52
53 err := deleteDeployKey(
54 &http.Client{Transport: reg},
55 ghrepo.New("OWNER", "REPO"),
56 "1234",
57 )
58
59 var httpErr api.HTTPError
60 require.ErrorAs(t, err, &httpErr)
61 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
62 assert.Contains(t, err.Error(), "HTTP 404")
63}

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected