testing

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorOrExit

type ErrorOrExit struct {
	// contains filtered or unexported fields
}

type TestParams

type TestParams struct {
	// contains filtered or unexported fields
}

func NewTestParams

func NewTestParams(script string, args ...string) *TestParams

func (*TestParams) ConfirmResponder added in v0.11.0

func (tp *TestParams) ConfirmResponder(f func(title, prompt string) (bool, error)) *TestParams

ConfirmResponder drives the shell-confirmation prompt for this run. Returning (false, nil) simulates declining ("n"); a non-nil error simulates an abort (Ctrl-C / Esc).

func (*TestParams) Keys added in v0.11.0

func (tp *TestParams) Keys(keys ...string) *TestParams

Keys scripts keystrokes for interactive prompts (pick, etc.). Each token is a named key ("up", "enter", "ctrl-c", "space", ...) or a "quoted literal" whose runes are typed in order.

func (*TestParams) NoTerminal added in v0.12.0

func (tp *TestParams) NoTerminal() *TestParams

func (*TestParams) RealShell added in v0.12.0

func (tp *TestParams) RealShell() *TestParams

NoTerminal runs as if neither stdin nor /dev/tty were a terminal - a CI job, a cron run, or an agent's tool call. This is what exercises the pre-flight guard and the --reply paths; without it, tests inherit "a terminal exists" so the rest of the suite can keep driving prompts with scripted keys. RealShell runs commands through the production executor instead of the mock, so the test exercises process spawning for real. Reserve it for behavior the mock cannot express - a command that cannot be started at all, say - since everything else is cheaper and more controllable through ShellResponder.

func (*TestParams) ShellOutput added in v0.12.0

func (tp *TestParams) ShellOutput(stdout, stderr string, exitCode int) *TestParams

ShellOutput is the common ShellResponder case: a fixed stdout/stderr/exit code for every command in the script.

func (*TestParams) ShellResponder added in v0.12.0

func (tp *TestParams) ShellResponder(
	f func(invocation core.ShellInvocation) (stdout, stderr string, exitCode int),
) *TestParams

ShellResponder supplies what each command "produced". Use it when a test asserts which variable received which stream - the default mock returns empty strings for both, which can't tell stdout and stderr apart.

func (*TestParams) StdinInput

func (tp *TestParams) StdinInput(stdinInput string) *TestParams

func (*TestParams) TermWidth added in v0.10.0

func (tp *TestParams) TermWidth(width int) *TestParams

type Tolerance added in v0.11.0

type Tolerance struct {
	// Skip bypasses the check entirely. Use for fragments / pseudo-code
	// that can't stand alone.
	Skip bool

	// MaxSeverity allows diagnostics with severity at or below this level
	// (case-insensitive: "hint" | "warning" | "info" | "error"). Empty means
	// no severity-based tolerance.
	//
	// Severity ordering (from rts/check/structs.go): Hint < Warning < Info < Error.
	MaxSeverity string

	// ExpectedCodes is a strict set of RAD codes (e.g. "RAD30001") that
	// MUST appear in the snippet's diagnostics. Any diagnostic with a code
	// outside this set fails (subject to MaxSeverity). Missing expected
	// codes also fail.
	ExpectedCodes []string

	// Reason is mandatory: a human-readable note explaining why this
	// entry exists. Test fails if an entry has Reason == "".
	Reason string
}

Tolerance describes the diagnostics we allow (or require) for a single doc snippet. The default for any snippet not in docSnippetTolerances is "must produce zero diagnostics of any severity".

Snippets are identified by "<relative-path-from-repo-root>#<8-hex-content-hash>" e.g. "docs-web/docs/guide/error-handling.md#a1b2c3d4". The hash changes whenever the snippet body changes, which orphans any matching tolerance entry and forces re-review on the next run.

Jump to

Keyboard shortcuts

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