MCPcopy
hub / github.com/rilldata/rill / verifyGithubRepoBranchContents

Function verifyGithubRepoBranchContents

cli/cmd/deploy/deploy_test.go:374–392  ·  view source on GitHub ↗
(t *testing.T, client *github.Client, remote string, branch string, changes map[string]string)

Source from the content-addressed store, hash-verified

372}
373
374func 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
394func getGithubAuthToken(t *testing.T) string {
395 // check if token is set via environment variable

Callers 2

verifyGithubRepoContentsFunction · 0.85

Calls 3

SplitGithubRemoteFunction · 0.92
ContextMethod · 0.65
GetContentMethod · 0.45

Tested by

no test coverage detected