treepadtest

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package treepadtest provides shared test helpers for packages that depend on treepad sub-package dependencies. Mirrors the pattern established by worktreetest.

Index

Constants

This section is empty.

Variables

View Source
var ErrExitNonZero = errors.New("exit status 1")

ErrExitNonZero is a sentinel for tests that expect a non-zero exit.

View Source
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.

View Source
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

func MainWorktreePorcelain(mainPath string) []byte

MainWorktreePorcelain builds porcelain output where mainPath has a real .git dir.

func NewPrinter

func NewPrinter(w io.Writer) *ui.Printer

NewPrinter returns a Printer backed by w, for asserting on log output.

func ThreeWorktreePorcelainWithMain

func ThreeWorktreePorcelainWithMain(mainPath, feat1Path, feat2Path string) []byte

ThreeWorktreePorcelainWithMain builds porcelain for three worktrees.

func TwoWorktreePorcelainWithMain

func TwoWorktreePorcelainWithMain(mainPath, featPath string) []byte

TwoWorktreePorcelainWithMain builds porcelain for a main + feat worktree pair.

func TwoWorktreePorcelainWithPrunable

func TwoWorktreePorcelainWithPrunable(mainPath, prunablePath string) []byte

TwoWorktreePorcelainWithPrunable builds porcelain where the second worktree is prunable.

func WorktreePorcelainWithPath

func WorktreePorcelainWithPath(branch, path string) []byte

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.

func (*DispatchRunner) Run

func (r *DispatchRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

type FakeHookCall

type FakeHookCall struct {
	Hooks []hook.HookEntry
	Data  hook.Data
}

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.

func (*FakeHookRunner) Run

func (f *FakeHookRunner) Run(_ context.Context, hooks []hook.HookEntry, data hook.Data) error

type FakeOpener

type FakeOpener struct {
	Paths []string
	Err   error
}

FakeOpener records Open calls and returns a canned error.

func (*FakeOpener) Open

type FakePassthroughRunner

type FakePassthroughRunner struct {
	Calls    []ptCall
	ExitCode int
	Err      error
}

fakePassthroughRunner records calls and returns a canned exit code.

func (*FakePassthroughRunner) Run

func (f *FakePassthroughRunner) Run(_ context.Context, dir, name string, args ...string) (int, error)

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

type RecordingRunner

type RecordingRunner struct {
	Inner *SeqRunner
	Calls [][]string // each entry is [name, args...]
}

RecordingRunner records every Run call and delegates to an inner SeqRunner.

func (*RecordingRunner) Run

func (r *RecordingRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

type RunResponse

type RunResponse struct {
	Output []byte
	Err    error
}

RunResponse is one entry in a SeqRunner's response queue.

type Runner

type Runner struct {
	Calls [][]string
	Err   error
}

func (*Runner) Run

func (f *Runner) Run(_ context.Context, name string, args ...string) ([]byte, error)

type SeqRunner

type SeqRunner struct {
	Responses []RunResponse
	Idx       int
}

SeqRunner returns responses in order across successive Run calls.

func (*SeqRunner) Run

func (s *SeqRunner) Run(_ context.Context, _ string, _ ...string) ([]byte, error)

type StaticRunner

type StaticRunner = worktreetest.StaticRunner

StaticRunner is re-exported from worktreetest for callers that only need a single canned response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL