| 291 | } |
| 292 | |
| 293 | func 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 | |
| 314 | func 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) |