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

Function StubFetchRelease

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

Source from the content-addressed store, hash-verified

279}
280
281func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) {
282 path := "repos/OWNER/REPO/releases/tags/v1.2.3"
283 if tagName == "" {
284 path = "repos/OWNER/REPO/releases/latest"
285 }
286
287 reg.Register(httpmock.REST("GET", path), httpmock.StringResponse(responseBody))
288
289 if tagName != "" {
290 reg.Register(
291 httpmock.GraphQL(`query RepositoryReleaseByTag\b`),
292 httpmock.GraphQLQuery(`{ "data": { "repository": { "release": null }}}`,
293 func(q string, vars map[string]interface{}) {
294 assert.Equal(t, owner, vars["owner"])
295 assert.Equal(t, repoName, vars["name"])
296 assert.Equal(t, tagName, vars["tagName"])
297 }),
298 )
299 }
300}
301
302func StubFetchRefSHA(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, sha string) {
303 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