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

Function Test_deleteAsset_httpError

pkg/cmd/release/delete-asset/delete_asset_test.go:205–224  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func Test_deleteAsset_httpError(t *testing.T) {
206 reg := &httpmock.Registry{}
207 defer reg.Verify(t)
208 reg.Register(
209 func(req *http.Request) bool {
210 return req.Method == http.MethodDelete &&
211 req.URL.EscapedPath() == "/repos/OWNER/REPO/releases/assets/1" &&
212 req.URL.Host == "api.github.com"
213 },
214 httpmock.StatusStringResponse(404, `{"message":"Not Found"}`),
215 )
216
217 httpClient := &http.Client{Transport: reg}
218 err := deleteAsset(httpClient, "example.com", safeurl.NewImmutableSafeURL("https://api.github.com/repos/OWNER/REPO/releases/assets/1"))
219
220 var httpErr api.HTTPError
221 require.ErrorAs(t, err, &httpErr)
222 assert.Equal(t, http.StatusNotFound, httpErr.StatusCode)
223 assert.Contains(t, err.Error(), "HTTP 404")
224}

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
StatusStringResponseFunction · 0.92
NewImmutableSafeURLFunction · 0.92
EqualMethod · 0.80
ContainsMethod · 0.80
deleteAssetFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected