(t *testing.T, client *github.Client, remote string, branch string, changes map[string]string)
| 372 | } |
| 373 | |
| 374 | func verifyGithubRepoBranchContents(t *testing.T, client *github.Client, remote string, branch string, changes map[string]string) { |
| 375 | t.Helper() |
| 376 | owner, repo, ok := gitutil.SplitGithubRemote(remote) |
| 377 | require.True(t, ok, "invalid github remote: %s", remote) |
| 378 | |
| 379 | var opts *github.RepositoryContentGetOptions |
| 380 | if branch != "" { |
| 381 | opts = &github.RepositoryContentGetOptions{Ref: branch} |
| 382 | } |
| 383 | |
| 384 | // TODO: consider downloading the repo and checking the files locally instead of making multiple API calls |
| 385 | for path, expectedContent := range changes { |
| 386 | con, _, _, err := client.Repositories.GetContents(t.Context(), owner, repo, path, opts) |
| 387 | require.NoError(t, err) |
| 388 | contents, err := con.GetContent() |
| 389 | require.NoError(t, err) |
| 390 | require.Equal(t, expectedContent, contents) |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | func getGithubAuthToken(t *testing.T) string { |
| 395 | // check if token is set via environment variable |
no test coverage detected