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

Function StubFetchRelease

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

Source from the content-addressed store, hash-verified

306}
307
308func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) {
309 path := "repos/OWNER/REPO/releases/tags/v1.2.3"
310 if tagName == "" {
311 path = "repos/OWNER/REPO/releases/latest"
312 }
313
314 reg.Register(httpmock.REST("GET", path), httpmock.StringResponse(responseBody))
315
316 if tagName != "" {
317 reg.Register(
318 httpmock.GraphQL(`query RepositoryReleaseByTag\b`),
319 httpmock.GraphQLQuery(`{ "data": { "repository": { "release": null }}}`,
320 func(q string, vars map[string]interface{}) {
321 assert.Equal(t, owner, vars["owner"])
322 assert.Equal(t, repoName, vars["name"])
323 assert.Equal(t, tagName, vars["tagName"])
324 }),
325 )
326 }
327}
328
329func StubFetchRefSHA(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, sha string) {
330 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