Documentation
¶
Overview ¶
Package treepadtest provides shared test helpers for packages that depend on treepad sub-package dependencies. Mirrors the pattern established by worktreetest.
Index ¶
- Variables
- func MainWorktreePorcelain(mainPath string) []byte
- func NewPrinter(w io.Writer) *ui.Printer
- func ThreeWorktreePorcelainWithMain(mainPath, feat1Path, feat2Path string) []byte
- func TwoWorktreePorcelainWithMain(mainPath, featPath string) []byte
- func TwoWorktreePorcelainWithPrunable(mainPath, prunablePath string) []byte
- func WorktreePorcelainWithPath(branch, path string) []byte
- type DispatchRunner
- type FakeHookCall
- type FakeHookRunner
- type FakeOpener
- type FakePassthroughRunner
- type FakeSyncer
- type RecordingRunner
- type RunResponse
- type Runner
- type SeqRunner
- type StaticRunner
Constants ¶
This section is empty.
Variables ¶
var ErrExitNonZero = errors.New("exit status 1")
ErrExitNonZero is a sentinel for tests that expect a non-zero exit.
var ThreeWorktreePorcelain = []byte(`worktree /repo/main
HEAD abc123
branch refs/heads/main
worktree /repo/feat
HEAD def456
branch refs/heads/feat
worktree /repo/other
HEAD ghi789
branch refs/heads/other
`)
ThreeWorktreePorcelain produces three worktrees.
var TwoWorktreePorcelain = []byte(`worktree /repo/main
HEAD abc123
branch refs/heads/main
worktree /repo/feat
HEAD def456
branch refs/heads/feat
`)
TwoWorktreePorcelain produces two worktrees; IsMain is false for both since the paths don't exist on disk.
Functions ¶
func MainWorktreePorcelain ¶
MainWorktreePorcelain builds porcelain output where mainPath has a real .git dir.
func NewPrinter ¶
NewPrinter returns a Printer backed by w, for asserting on log output.
func ThreeWorktreePorcelainWithMain ¶
ThreeWorktreePorcelainWithMain builds porcelain for three worktrees.
func TwoWorktreePorcelainWithMain ¶
TwoWorktreePorcelainWithMain builds porcelain for a main + feat worktree pair.
func TwoWorktreePorcelainWithPrunable ¶
TwoWorktreePorcelainWithPrunable builds porcelain where the second worktree is prunable.
func WorktreePorcelainWithPath ¶
WorktreePorcelainWithPath builds porcelain output with a controllable path.
Types ¶
type DispatchRunner ¶
type DispatchRunner struct {
// Classify returns a routing key for the call, or "" to fall through to Fallback.
Classify func(name string, args []string) string
// Routes maps routing keys to ordered response queues consumed one-by-one.
Routes map[string][]RunResponse
Fallback *SeqRunner
// contains filtered or unexported fields
}
DispatchRunner routes Run calls to per-key responses based on a classifier. Calls that return an empty key fall through to Fallback.
type FakeHookCall ¶
FakeHookCall records a single invocation of FakeHookRunner.Run.
type FakeHookRunner ¶
type FakeHookRunner struct {
Calls []FakeHookCall
Err error
}
FakeHookRunner records hook calls and returns a canned error.
type FakeOpener ¶
FakeOpener records Open calls and returns a canned error.
type FakePassthroughRunner ¶
fakePassthroughRunner records calls and returns a canned exit code.
type FakeSyncer ¶
type FakeSyncer struct {
Calls []internalsync.Config
Result internalsync.SyncResult
Err error
}
FakeSyncer records Sync calls and returns a canned result and error.
func (*FakeSyncer) Sync ¶
func (f *FakeSyncer) Sync(_ []string, cfg internalsync.Config) (internalsync.SyncResult, error)
type RecordingRunner ¶
RecordingRunner records every Run call and delegates to an inner SeqRunner.
type RunResponse ¶
RunResponse is one entry in a SeqRunner's response queue.
type SeqRunner ¶
type SeqRunner struct {
Responses []RunResponse
Idx int
}
SeqRunner returns responses in order across successive Run calls.
type StaticRunner ¶
type StaticRunner = worktreetest.StaticRunner
StaticRunner is re-exported from worktreetest for callers that only need a single canned response.