testhelpers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const AzlDevBinaryName = "azldev"

Default binary name for the main AZL Dev CLI command.

Variables

This section is empty.

Functions

func FindTestBinary

func FindTestBinary() (string, error)

FindTestBinary finds the azldev binary to use for testing. It first checks if the testing tools have passed an environment variable with the path to the azldev binary. If not, it will look for the azldev binary in the out directory of the repo. If all else fails, it will look for the azldev binary in the $PATH.

func FindTestDockerDirectory

func FindTestDockerDirectory() (string, error)

FindTestDockerDirectory finds the directory containing the collateral files for creating the testing container.

Types

type ScenarioTest

type ScenarioTest interface {
	// Runs the scenario test, returning results.
	Run(t *testing.T) (results TestResults, err error)
}

ScenarioTest is an interface describing a scenario test.

type TestResults

type TestResults struct {
	// Basics
	ExitCode int

	// We exclude stdout and stderr from JSON serialization because they are best separately saved.
	Stdout string `json:"-"`
	Stderr string `json:"-"`

	// We exclude the workdir path from JSON serialization as well; it's not stable.
	Workdir string `json:"-"`
}

TestResults is a struct describing the results of a scenario test.

func (*TestResults) AssertNonZeroExitCode

func (r *TestResults) AssertNonZeroExitCode(t *testing.T)

AssertNonZeroExitCode asserts that the exit code of the test is non-zero. If the assertion fails, it dumps the test summary to the test log.

func (*TestResults) AssertStderrContains

func (r *TestResults) AssertStderrContains(t *testing.T, expected string)

AssertStderrContains asserts that the stderr output of the test contains the given string. If the assertion fails, it dumps the test summary to the test log.

func (*TestResults) AssertStdoutContains

func (r *TestResults) AssertStdoutContains(t *testing.T, expected string)

AssertStdoutContains asserts that the stdout output of the test contains the given string. If the assertion fails, it dumps the test summary to the test log.

func (*TestResults) AssertZeroExitCode

func (r *TestResults) AssertZeroExitCode(t *testing.T)

AssertZeroExitCode asserts that the exit code of the test is 0. If the assertion fails, it dumps the test summary to the test log.

func (*TestResults) DumpSummary

func (r *TestResults) DumpSummary(t *testing.T)

DumpSummary writes a brief summary of the test execution results to the test log. This is typically only invoked for failure cases, or in verbose modes.

Jump to

Keyboard shortcuts

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