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

Function Test_deleteGPGKeyHTTPError

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

Source from the content-addressed store, hash-verified

20)
21
22func Test_deleteGPGKeyHTTPError(t *testing.T) {
23 reg := &httpmock.Registry{}
24 defer reg.Verify(t)
25 reg.Register(
26 httpmock.REST("DELETE", "user/gpg_keys/123"),
27 httpmock.WithHeader(
28 httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`),
29 "Content-Type", "application/json",
30 ),
31 )
32
33 err := deleteGPGKey(&http.Client{Transport: reg}, "github.com", "123")
34
35 var httpErr api.HTTPError
36 require.ErrorAs(t, err, &httpErr)
37 assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode)
38 assert.Contains(t, err.Error(), "HTTP 500")
39 assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys/123)")
40}
41
42func Test_getGPGKeysHTTPError(t *testing.T) {
43 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected