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

Function TestGetSSHKeyHTTPError

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

Source from the content-addressed store, hash-verified

229}
230
231func TestGetSSHKeyHTTPError(t *testing.T) {
232 reg := &httpmock.Registry{}
233 defer reg.Verify(t)
234 reg.Register(
235 httpmock.REST("GET", "user/keys/1234"),
236 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
237 )
238
239 key, err := getSSHKey(&http.Client{Transport: reg}, "github.com", "1234")
240
241 assert.Nil(t, key)
242 var httpErr api.HTTPError
243 require.ErrorAs(t, err, &httpErr)
244 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
245 assert.Contains(t, err.Error(), "HTTP 404")
246}

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected