appcmdtesting

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package appcmdtesting contains test utilities for appcmd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	options ...RunOption,
)

Run runs the command created by newCommand with the specified options.

Types

type RunOption

type RunOption func(*runOptions)

RunOption is a new option for Run.

func WithArgs

func WithArgs(args ...string) RunOption

WithArgs adds the given args.

func WithEnv

func WithEnv(newEnv func(use string) map[string]string) RunOption

WithEnv will attach the given environment variable map created by newEnv.

The default is no environment variables.

func WithExpectedExitCode

func WithExpectedExitCode(expectedExitCode int) RunOption

WithExpectedExitCode will result in Run checking that the exit code is the expected value.

By default, Run will check that the exit code is 0.

func WithExpectedExitCodes

func WithExpectedExitCodes(expectedExitCodes ...int) RunOption

WithExpectedExitCodes will result in Run checking that the exit code is one of the expected values.

By default, Run will check that the exit code is 0.

func WithExpectedStderr

func WithExpectedStderr(expectedStderr string) RunOption

WithExpectedStdout will result in an error if the stderr does not exactly equal the given string.

Note that this can be called with empty, which will result in Run verifying that the stderr is empty.

func WithExpectedStderrPartials

func WithExpectedStderrPartials(expectedStderrPartials ...string) RunOption

WithExpectedStderrPartials will result in Run checking if all the given strings are contained within stderr.

Note that this can be called with empty, which will result in Run verifying that the stderr is empty.

func WithExpectedStdout

func WithExpectedStdout(expectedStdout string) RunOption

WithExpectedStdout will result in an error if the stdout does not exactly equal the given string.

Note that this can be called with empty, which will result in Run verifying that the stdout is empty.

func WithStderr

func WithStderr(stderr io.Writer) RunOption

WithStdout will attach the given stderr to write to.

func WithStdin

func WithStdin(stdin io.Reader) RunOption

WithStdin will attach the given stdin to read from.

func WithStdout

func WithStdout(stdout io.Writer) RunOption

WithStdout will attach the given stdout to write to.

Jump to

Keyboard shortcuts

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