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

Function TestUploadDeployKeyHTTPError

pkg/cmd/repo/deploy-key/add/add_test.go:91–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestUploadDeployKeyHTTPError(t *testing.T) {
92 reg := &httpmock.Registry{}
93 defer reg.Verify(t)
94
95 reg.Register(
96 httpmock.REST("POST", "repos/OWNER/REPO/keys"),
97 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
98 )
99
100 err := uploadDeployKey(
101 &http.Client{Transport: reg},
102 ghrepo.New("OWNER", "REPO"),
103 strings.NewReader("PUBKEY\n"),
104 "my sacred key",
105 false,
106 )
107
108 var httpErr api.HTTPError
109 require.ErrorAs(t, err, &httpErr)
110 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
111 assert.Contains(t, err.Error(), "HTTP 404")
112}

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected