Documentation
¶
Overview ¶
Package testutil provides shared test helpers: fake implementations of internal/repo.Finder and internal/runner.Runner interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeGitRepo ¶
MakeGitRepo creates a minimal git repository directory (with a .git dir) under parent and returns its path.
func RunTestMain ¶ added in v0.2.0
RunTestMain unsets all GIT_ITER_* environment variables, runs the test suite m, restores the original environment variables, and terminates the process with m's exit code. TestMain implementations in packages can simply call testutil.RunTestMain(m).
Types ¶
type FakeFinder ¶
FakeFinder is a test double for repo.Finder that returns a pre-configured list of paths.
type FakeRunner ¶
type FakeRunner struct {
Calls []RunCall
Output string
Err error
// contains filtered or unexported fields
}
FakeRunner is a test double for runner.Runner. It records every call and writes Output to stdout; returns Err on each call.
type SubcommandHandler ¶
SubcommandHandler is invoked by SubcommandRunner when a matching subcommand is executed.
type SubcommandRunner ¶
type SubcommandRunner struct {
// contains filtered or unexported fields
}
SubcommandRunner is a mock runner that dispatches to handlers based on command[1].
func NewSubcommandRunner ¶
func NewSubcommandRunner() *SubcommandRunner
NewSubcommandRunner creates a new SubcommandRunner.
func (*SubcommandRunner) Calls ¶
func (r *SubcommandRunner) Calls() [][]string
Calls returns a copy of all recorded calls.
func (*SubcommandRunner) On ¶
func (r *SubcommandRunner) On(subcmd string, h SubcommandHandler)
On registers a handler for a given git subcommand (e.g. "rev-parse", "symbolic-ref").