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

Function Test_getGPGKeysHTTPError

pkg/cmd/gpg-key/delete/delete_test.go:42–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func Test_getGPGKeysHTTPError(t *testing.T) {
43 reg := &httpmock.Registry{}
44 defer reg.Verify(t)
45 reg.Register(
46 httpmock.QueryMatcher("GET", "user/gpg_keys", url.Values{"per_page": []string{"100"}}),
47 httpmock.WithHeader(
48 httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`),
49 "Content-Type", "application/json",
50 ),
51 )
52
53 keys, err := getGPGKeys(&http.Client{Transport: reg}, "github.com")
54
55 assert.Nil(t, keys)
56 var httpErr api.HTTPError
57 require.ErrorAs(t, err, &httpErr)
58 assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode)
59 assert.Contains(t, err.Error(), "HTTP 500")
60 assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys?per_page=100)")
61}
62
63func TestNewCmdDelete(t *testing.T) {
64 tests := []struct {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected