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

Function TestFetchReleaseNotFoundWhenBothLookupsMiss

pkg/cmd/release/shared/fetch_test.go:165–182  ·  view source on GitHub ↗

TestFetchReleaseNotFoundWhenBothLookupsMiss pins the sentinel that FetchRelease reports when neither the published nor the draft lookup finds a release, since the published lookup now recognises a miss from an HTTPError rather than from the response status directly.

(t *testing.T)

Source from the content-addressed store, hash-verified

163// neither the published nor the draft lookup finds a release, since the published lookup now
164// recognises a miss from an HTTPError rather than from the response status directly.
165func TestFetchReleaseNotFoundWhenBothLookupsMiss(t *testing.T) {
166 fakeHTTP := &httpmock.Registry{}
167
168 repo, err := ghrepo.FromFullName("owner/repo")
169 require.NoError(t, err)
170
171 fakeHTTP.Register(
172 httpmock.REST("GET", "repos/owner/repo/releases/tags/v9.9.9"),
173 httpmock.JSONErrorResponse(404, api.HTTPError{StatusCode: 404, Message: "Not Found"}),
174 )
175 fakeHTTP.Register(
176 httpmock.GraphQL(`query RepositoryReleaseByTag\b`),
177 httpmock.StringResponse(`{"data": {"repository": {"release": null}}}`),
178 )
179
180 _, err = FetchRelease(context.Background(), &http.Client{Transport: fakeHTTP}, repo, "v9.9.9")
181 require.ErrorIs(t, err, ErrReleaseNotFound)
182}
183
184func TestDigestAlgForRef(t *testing.T) {
185 tests := []struct {

Callers

nothing calls this directly

Calls 7

RegisterMethod · 0.95
FromFullNameFunction · 0.92
RESTFunction · 0.92
JSONErrorResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FetchReleaseFunction · 0.85

Tested by

no test coverage detected