MCPcopy
hub / github.com/cli/cli / StubFetchRelease

Function StubFetchRelease

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

Source from the content-addressed store, hash-verified

291}
292
293func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) {
294 path := "repos/OWNER/REPO/releases/tags/v1.2.3"
295 if tagName == "" {
296 path = "repos/OWNER/REPO/releases/latest"
297 }
298
299 reg.Register(httpmock.REST("GET", path), httpmock.StringResponse(responseBody))
300
301 if tagName != "" {
302 reg.Register(
303 httpmock.GraphQL(`query RepositoryReleaseByTag\b`),
304 httpmock.GraphQLQuery(`{ "data": { "repository": { "release": null }}}`,
305 func(q string, vars map[string]interface{}) {
306 assert.Equal(t, owner, vars["owner"])
307 assert.Equal(t, repoName, vars["name"])
308 assert.Equal(t, tagName, vars["tagName"])
309 }),
310 )
311 }
312}
313
314func StubFetchRefSHA(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, sha string) {
315 path := fmt.Sprintf("repos/%s/%s/git/ref/tags/%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