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

Function StubFetchRelease

pkg/cmd/release/shared/fetch.go:301–320  ·  view source on GitHub ↗
(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string)

Source from the content-addressed store, hash-verified

299}
300
301func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) {
302 path := "repos/OWNER/REPO/releases/tags/v1.2.3"
303 if tagName == "" {
304 path = "repos/OWNER/REPO/releases/latest"
305 }
306
307 reg.Register(httpmock.REST("GET", path), httpmock.StringResponse(responseBody))
308
309 if tagName != "" {
310 reg.Register(
311 httpmock.GraphQL(`query RepositoryReleaseByTag\b`),
312 httpmock.GraphQLQuery(`{ "data": { "repository": { "release": null }}}`,
313 func(q string, vars map[string]any) {
314 assert.Equal(t, owner, vars["owner"])
315 assert.Equal(t, repoName, vars["name"])
316 assert.Equal(t, tagName, vars["tagName"])
317 }),
318 )
319 }
320}
321
322func StubFetchRefSHA(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, sha string) {
323 path := fmt.Sprintf("repos/%s/%s/git/ref/tags%%2F%s", owner, repoName, tagName)

Callers 8

Test_deleteAssetRunFunction · 0.92
Test_deleteRunFunction · 0.92
Test_viewRunFunction · 0.92
Test_downloadRunFunction · 0.92
Test_editRunFunction · 0.92

Calls 6

RESTFunction · 0.92
StringResponseFunction · 0.92
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
EqualMethod · 0.80
RegisterMethod · 0.45

Tested by 8

Test_deleteAssetRunFunction · 0.74
Test_deleteRunFunction · 0.74
Test_viewRunFunction · 0.74
Test_downloadRunFunction · 0.74
Test_editRunFunction · 0.74