Documentation
¶
Overview ¶
Package testutil holds helpers for tests only. Production code must not import it.
Index ¶
- Constants
- Variables
- func Author(n int) gitx.Identity
- func BareRepo(t testing.TB, dir string) *gitx.Git
- func Commit(t testing.TB, g *gitx.Git, branch, message string, files map[string]string) string
- func FakeGitHubToken() string
- func Main(m *testing.M, after ...func())
- func ValidateSchema(t testing.TB, name string, raw []byte)
- type Clock
- type SeqReader
Constants ¶
const Delete = "\x00delete"
Delete, as a file's content in Commit, removes that path.
Variables ¶
var Base = time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
Base is the time every test commit is anchored to, so SHAs are stable.
Functions ¶
func Commit ¶
Commit adds a commit on refs/heads/<branch> that applies files on top of the branch's current tree, using plumbing only (no worktree). It returns the new commit's SHA.
func FakeGitHubToken ¶
func FakeGitHubToken() string
FakeGitHubToken returns a string shaped like a GitHub PAT, so Gitleaks flags it. It is assembled at run time so this source file never contains a token-shaped literal (our own repo is scanned too).
func Main ¶
Main runs a package's tests, then each after func, then removes the git isolation directory the test binary made, so test runs leave nothing in the temp directory, and exits with the tests' code. Every package whose tests run git calls it from TestMain; after is for a package's own teardown.