| 299 | } |
| 300 | |
| 301 | func 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 | |
| 322 | func 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) |