Documentation
¶
Overview ¶
Package testutil provides small polling helpers shared across test packages, so individual tests don't re-derive deadline/poll loops (which tend to drift in interval and failure messaging).
Index ¶
- func Consistently(t fataler, duration, interval time.Duration, check func() string)
- func Eventually(t fataler, timeout, interval time.Duration, cond func() bool, msgf string, ...)
- func InitRepo(t gitTB) string
- func InitRepoWithBranch(t gitTB, branch string) string
- func RunGit(t gitTB, dir string, args ...string) string
- func WaitForAtomic[T cmp.Ordered](t fataler, load func() T, want T, timeout time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Consistently ¶
Consistently polls check for the full duration at the given interval, failing the test the first time check returns a non-empty failure message. It is the inverse of Eventually: the condition must hold the whole time.
func Eventually ¶
func Eventually(t fataler, timeout, interval time.Duration, cond func() bool, msgf string, args ...any)
Eventually polls cond until it returns true or timeout elapses, failing the test (via t.Fatalf with the formatted message) on timeout.
func InitRepo ¶
func InitRepo(t gitTB) string
InitRepo creates a throwaway git repository under t.TempDir() with a single committed README on the default "main" branch and returns its path.
func InitRepoWithBranch ¶
InitRepoWithBranch is InitRepo with a caller-chosen initial branch name.
func RunGit ¶
RunGit runs `git args...` in dir and returns its trimmed combined output, failing the test on error. It strips inherited GIT_DIR/GIT_WORK_TREE/ GIT_INDEX_FILE (which a surrounding pre-push hook or harness may set) so the command always operates on dir, and pins a deterministic author/committer identity so commits succeed without depending on the machine's global git config.
Types ¶
This section is empty.