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

Function Test_userKeysHTTPError

pkg/cmd/gpg-key/list/list_test.go:34–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32}
33
34func Test_userKeysHTTPError(t *testing.T) {
35 reg := &httpmock.Registry{}
36 defer reg.Verify(t)
37 reg.Register(
38 httpmock.QueryMatcher("GET", "user/gpg_keys", url.Values{"per_page": []string{"100"}}),
39 httpmock.WithHeader(
40 httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`),
41 "Content-Type", "application/json",
42 ),
43 )
44
45 keys, err := userKeys(&http.Client{Transport: reg}, "github.com", "")
46
47 assert.Nil(t, keys)
48 var httpErr api.HTTPError
49 require.ErrorAs(t, err, &httpErr)
50 assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode)
51 assert.Contains(t, err.Error(), "HTTP 500")
52 assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys?per_page=100)")
53}
54
55func Test_userKeysForUser(t *testing.T) {
56 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
QueryMatcherFunction · 0.92
WithHeaderFunction · 0.92
StatusStringResponseFunction · 0.92
userKeysFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected