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

Function TestUserKeysHTTPError

pkg/cmd/ssh-key/shared/user_keys_test.go:13–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestUserKeysHTTPError(t *testing.T) {
14 reg := &httpmock.Registry{}
15 defer reg.Verify(t)
16 reg.Register(
17 httpmock.REST("GET", "user/keys"),
18 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
19 )
20
21 keys, err := UserKeys(&http.Client{Transport: reg}, "github.com", "")
22
23 assert.Nil(t, keys)
24 var httpErr api.HTTPError
25 require.ErrorAs(t, err, &httpErr)
26 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
27 assert.Contains(t, err.Error(), "HTTP 404")
28}

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected