{"modulePath":"github.com/uber/submitqueue","version":"v0.3.0-20261125210437-add1a4bd2ea2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githubtestrepo\n\nPackage githubtestrepo gives tests real pull requests on github.com to land.\n\nThe GitHub merger and the GitHub change provider talk to GitHub's REST API, and only real pull requests show what that API actually does — an in-process fake encodes only our reading of the docs. The suites that verify them (the merger extension test and TestGitHubLandE2E) share this package to open branches and pull requests, link them into stacks, push a new head, read back whether GitHub merged them and with which commit, and remove what they opened.\n\nNew skips the calling test unless SQ\\_GITHUB\\_TOKEN and SQ\\_GITHUB\\_TEST\\_REPO (\"owner/repo\") are set, so runs without the credential never touch GitHub. Where the credential is expected — SQ\\_GITHUB\\_TEST\\_REQUIRED=true, which CI sets on every run that can read its secrets — a missing one fails the test instead, so a deleted secret cannot quietly turn these suites into skips. A token GitHub rejects (expired or revoked) always fails. Fixtures are named under sq-it/\\\u003crun id\u003e/ and closed and deleted when the test ends; what a test merges stays on the repository's default branch.\n\n## Constants\n\n```go\nconst (\n\t// TokenEnv names the variable holding a token with write access to the\n\t// test repository.\n\tTokenEnv = \"SQ_GITHUB_TOKEN\"\n\t// RepoEnv names the variable holding the test repository, \"owner/repo\".\n\tRepoEnv = \"SQ_GITHUB_TEST_REPO\"\n\t// RequiredEnv names the variable that, when \"true\", makes a missing\n\t// TokenEnv or RepoEnv fail the test rather than skip it.\n\tRequiredEnv = \"SQ_GITHUB_TEST_REQUIRED\"\n\n\t// Host is the GitHub instance the test repository's change URIs name.\n\tHost = \"github.com\"\n\t// APIBaseURL is the REST API root for Host.\n\tAPIBaseURL = \"https://api.github.com\"\n)\n```\n\n## Types\n\n```go\ntype Pull struct {\n\t// Number is the pull request number.\n\tNumber int\n\t// Branch is the pull request's head branch.\n\tBranch string\n\t// Head is the head commit the pull request was opened at.\n\tHead string\n}\n```\nPull is a fixture pull request.\n\n```go\ntype PullState struct {\n\t// State is \"open\" or \"closed\".\n\tState string `json:\"state\"`\n\t// Merged reports whether the pull request was merged.\n\tMerged bool `json:\"merged\"`\n}\n```\nPullState is what GitHub reports about a fixture pull request.\n\n```go\ntype TestRepo struct {\n\t// contains filtered or unexported fields\n}\n```\nTestRepo creates fixtures in the test repository and removes them when the test ends.\n\n```go\nfunc New(t testing.TB) *TestRepo\n```\nNew returns a TestRepo for the configured repository. When the credential or repository is not configured it skips the test, or fails it if RequiredEnv is \"true\".\n\n```go\nfunc (r *TestRepo) AwaitPullHead(number int, head string)\n```\nAwaitPullHead waits until GitHub reports head as the pull request's head. A push reaches the pull request asynchronously, so a staleness check run before that would compare against the old head. Bounded by the test runner's timeout.\n\n```go\nfunc (r *TestRepo) CommitFile(branch, path, content string) string\n```\nCommitFile writes a file on branch and returns the new head commit.\n\n```go\nfunc (r *TestRepo) FileOnTrunk(path string) bool\n```\nFileOnTrunk reports whether path exists on the trunk.\n\n```go\nfunc (r *TestRepo) FilePath(name string) string\n```\nFilePath is the path of the file a fixture named name adds.\n\n```go\nfunc (r *TestRepo) HTTPClient() *http.Client\n```\nHTTPClient is an authenticated client rooted at APIBaseURL.\n\n```go\nfunc (r *TestRepo) MergeCommit(number int) string\n```\nMergeCommit is the commit GitHub's merged event records for a pull request, or \"\" when it has none.\n\n```go\nfunc (r *TestRepo) OpenChain(name string, n int) []Pull\n```\nOpenChain opens n pull requests stacked by base branch without creating a GitHub stack.\n\n```go\nfunc (r *TestRepo) OpenPull(name, base string) Pull\n```\nOpenPull opens one pull request against base that adds a file unique to it.\n\n```go\nfunc (r *TestRepo) OpenStack(name string, n int) []Pull\n```\nOpenStack opens n pull requests, each adding its own file, the first based on the trunk and each later one on the branch below it, and links them into a GitHub stack.\n\n```go\nfunc (r *TestRepo) Owner() string\n```\nOwner is the test repository's owner.\n\n```go\nfunc (r *TestRepo) PullState(number int) PullState\n```\nPullState reads a pull request's current state.\n\n```go\nfunc (r *TestRepo) Repo() string\n```\nRepo is the test repository's name.\n\n```go\nfunc (r *TestRepo) RunID() string\n```\nRunID uniquely names this test run's fixtures.\n\n```go\nfunc (r *TestRepo) Token() string\n```\nToken is the credential the test repository is reached with.\n\n```go\nfunc (r *TestRepo) Trunk() string\n```\nTrunk is the test repository's default branch.\n\n```go\nfunc (r *TestRepo) URI(p Pull) string\n```\nURI is the change URI naming p at the head it was opened with.\n\n```go\nfunc (r *TestRepo) URIs(pulls ...Pull) []string\n```\nURIs is URI for each pull request, in order.\n\n","path":"github.com/uber/submitqueue/test/testutil/githubtestrepo","name":"githubtestrepo","synopsis":"Package githubtestrepo gives tests real pull requests on github.com to land.","isRedistributable":true}
