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

Function TestDeleteSSHKeyHTTPError

pkg/cmd/ssh-key/delete/delete_test.go:215–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

213}
214
215func TestDeleteSSHKeyHTTPError(t *testing.T) {
216 reg := &httpmock.Registry{}
217 defer reg.Verify(t)
218 reg.Register(
219 httpmock.REST("DELETE", "user/keys/1234"),
220 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
221 )
222
223 err := deleteSSHKey(&http.Client{Transport: reg}, "github.com", "1234")
224
225 var httpErr api.HTTPError
226 require.ErrorAs(t, err, &httpErr)
227 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
228 assert.Contains(t, err.Error(), "HTTP 404")
229}
230
231func TestGetSSHKeyHTTPError(t *testing.T) {
232 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected