appcmdtesting

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 13 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 RunCommandExitCode

func RunCommandExitCode(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	stdout io.Writer,
	stderr io.Writer,
	args ...string,
)

RunCommandExitCode runs the command and compares the exit code.

func RunCommandExitCodeStderr

func RunCommandExitCodeStderr(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStderr string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodeStderr runs the command and compares the exit code and stderr output.

func RunCommandExitCodeStderrContains added in v1.20.0

func RunCommandExitCodeStderrContains(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStderrPartials []string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodeStderrContains runs the command and compares the exit code and stderr output with the passed partial messages.

func RunCommandExitCodeStdout

func RunCommandExitCodeStdout(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStdout string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodeStdout runs the command and compares the exit code and stdout output.

func RunCommandExitCodeStdoutFile added in v1.10.0

func RunCommandExitCodeStdoutFile(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStdout string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodeStdoutFile runs the command and compares the exit code and stdout output.

func RunCommandExitCodeStdoutStderr

func RunCommandExitCodeStdoutStderr(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStdout string,
	expectedStderr string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodeStdoutStderr runs the command and compares the exit code, stdout, and stderr output.

func RunCommandExitCodeStdoutStdinFile added in v1.10.0

func RunCommandExitCodeStdoutStdinFile(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCode int,
	expectedStdout string,
	newEnv func(use string) map[string]string,
	stdinFile string,
	args ...string,
)

RunCommandExitCodeStdoutStdinFile runs the command and allows a stdinFile to be opened and piped into the command.

func RunCommandExitCodes added in v1.32.0

func RunCommandExitCodes(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCodes []int,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	stdout io.Writer,
	stderr io.Writer,
	args ...string,
)

RunCommandExitCodes runs the command and compares the exit code to the expected exit codes.

It would be nice if we could do:

type IntOrInts interface {
  int | []int
}

func RunCommandExitCode[I IntOrInts](expectedExitCode I)

However we can't: https://github.com/golang/go/issues/49206

func RunCommandExitCodesStderr added in v1.32.0

func RunCommandExitCodesStderr(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedExitCodes []int,
	expectedStderr string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandExitCodesStderr runs the command and compares the exit codes and stderr output.

func RunCommandSuccess

func RunCommandSuccess(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	stdout io.Writer,
	args ...string,
)

RunCommandSuccess runs the command and makes sure it was successful.

func RunCommandSuccessStdout

func RunCommandSuccessStdout(
	t *testing.T,
	newCommand func(use string) *appcmd.Command,
	expectedStdout string,
	newEnv func(use string) map[string]string,
	stdin io.Reader,
	args ...string,
)

RunCommandSuccessStdout runs the command and makes sure it was successful, and compares the stdout output.

Types

This section is empty.

Jump to

Keyboard shortcuts

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