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

Function TestRepoKeysHTTPError

pkg/cmd/repo/deploy-key/list/list_test.go:138–156  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

136}
137
138func TestRepoKeysHTTPError(t *testing.T) {
139 reg := &httpmock.Registry{}
140 defer reg.Verify(t)
141
142 reg.Register(
143 httpmock.REST("GET", "repos/OWNER/REPO/keys"),
144 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`),
145 )
146
147 _, err := repoKeys(
148 &http.Client{Transport: reg},
149 ghrepo.New("OWNER", "REPO"),
150 )
151
152 var httpErr api.HTTPError
153 require.ErrorAs(t, err, &httpErr)
154 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
155 assert.Contains(t, err.Error(), "HTTP 404")
156}

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected