Documentation
¶
Index ¶
- func AssertNoANSI(t *testing.T, value string)
- func CaptureOutput(fn func()) (string, string)
- func CaptureStdout(fn func()) string
- func Command(cmd *cobra.Command, mutators ...OptionsMutator) *cobra.Command
- func Fixture(t *testing.T, path string) string
- func JSON(t *testing.T, w http.ResponseWriter, data map[string]any)
- func MustExecute(t *testing.T, cmd interface{ ... })
- func RawJSON(t *testing.T, w http.ResponseWriter, body string)
- func SetColorEnabled(t *testing.T, enabled bool)
- func SetStdoutIsTerminal(t *testing.T, enabled bool)
- func Setup(t *testing.T, handler http.HandlerFunc) *httptest.Server
- func SetupAdmin(t *testing.T, handler http.HandlerFunc) *httptest.Server
- func TestOptions(mutators ...OptionsMutator) cmdutil.Options
- func WithOptions(cmd *cobra.Command, opts cmdutil.Options) *cobra.Command
- type OptionsMutator
- func Debug(value bool) OptionsMutator
- func DryRun(value bool) OptionsMutator
- func JQ(expr string) OptionsMutator
- func JSONOutput() OptionsMutator
- func NoColor(value bool) OptionsMutator
- func NoImage(value bool) OptionsMutator
- func NoInput(value bool) OptionsMutator
- func NonInteractive(value bool) OptionsMutator
- func PlainOutput() OptionsMutator
- func Quiet(value bool) OptionsMutator
- func Stderr(w io.Writer) OptionsMutator
- func Stdin(r io.Reader) OptionsMutator
- func Stdout(w io.Writer) OptionsMutator
- func Yes(value bool) OptionsMutator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoANSI ¶
func CaptureOutput ¶
CaptureOutput captures both stdout and stderr during fn execution. Access is serialized so parallel tests do not race on global descriptors.
func CaptureStdout ¶
func CaptureStdout(fn func()) string
CaptureStdout captures os.Stdout output during fn execution. Access is serialized so parallel tests do not race on global os.Stdout.
func Command ¶
func Command(cmd *cobra.Command, mutators ...OptionsMutator) *cobra.Command
Command applies test options and any requested mutations to a command.
func MustExecute ¶
MustExecute runs a command in tests and fails immediately on error.
func RawJSON ¶
func RawJSON(t *testing.T, w http.ResponseWriter, body string)
RawJSON writes a literal JSON response body.
func SetColorEnabled ¶
func SetStdoutIsTerminal ¶
func Setup ¶
Setup creates a mock HTTP server and temp config for command tests. Returns the server. Cleanup is automatic via t.Cleanup.
func SetupAdmin ¶ added in v0.3.0
SetupAdmin creates a mock admin HTTP server and temp admin config for command tests. Cleanup is automatic via t.Cleanup.
func TestOptions ¶
func TestOptions(mutators ...OptionsMutator) cmdutil.Options
TestOptions returns the default per-command options used by command tests.
Types ¶
type OptionsMutator ¶
func Debug ¶
func Debug(value bool) OptionsMutator
func DryRun ¶
func DryRun(value bool) OptionsMutator
func JQ ¶
func JQ(expr string) OptionsMutator
func JSONOutput ¶
func JSONOutput() OptionsMutator
func NoColor ¶
func NoColor(value bool) OptionsMutator
func NoImage ¶
func NoImage(value bool) OptionsMutator
func NoInput ¶
func NoInput(value bool) OptionsMutator
func NonInteractive ¶ added in v0.4.0
func NonInteractive(value bool) OptionsMutator
func PlainOutput ¶
func PlainOutput() OptionsMutator
func Quiet ¶
func Quiet(value bool) OptionsMutator
func Stderr ¶
func Stderr(w io.Writer) OptionsMutator
func Stdin ¶
func Stdin(r io.Reader) OptionsMutator
func Stdout ¶
func Stdout(w io.Writer) OptionsMutator
func Yes ¶
func Yes(value bool) OptionsMutator