Documentation
¶
Overview ¶
Package execxtest provides a scripted fake execx.Runner for transcript tests: each expected call is asserted in order and answered with a recorded result, so tests pin the exact argument vectors the core sends to git and gh without running either.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
// Name is the expected Cmd.Name, for example "git".
Name string
// Args is the expected exact argument vector.
Args []string
// Dir is the expected Cmd.Dir; empty skips the check because
// many tests build paths from t.TempDir().
Dir string
// Env, when non-nil, is the expected exact Cmd.Env.
Env []string
// Stdin, when non-empty, is the expected full standard input;
// empty skips the check, matching the Dir convention.
Stdin string
// CheckStdin optionally checks a structured payload without matching
// dynamic content byte-for-byte.
CheckStdin func(*testing.T, string)
// Stdout, Stderr, and Exit form the scripted Result.
Stdout string
Stderr string
Exit int
// Err, when non-nil, is returned instead of a Result, modeling
// a command that could not run at all.
Err error
}
Call is one expected invocation and its scripted response.
type Script ¶
Script is a Runner that fails the test on any call that deviates from the recorded transcript.
func (*Script) AssertExhausted ¶
func (s *Script) AssertExhausted()
AssertExhausted fails the test unless every scripted call was consumed. Tests use it to prove fail-closed short circuits: an operation that must be denied before touching git leaves an empty script untouched.
func (*Script) Run ¶
Run asserts that c matches the next scripted call and returns its recorded response.
func (*Script) StdinAt ¶ added in v0.4.0
StdinAt returns the standard input the i-th consumed call received (0-based, "" when that call had none). It exists for bodies a test wants to assert on structurally — parse the posted issue body and check the record — rather than spell out byte-for-byte in a Call.Stdin expectation, which would only restate the code that produced it.