expect

package
v0.0.0-...-a9b44cb Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package expect provides a set of simple concrete test.Comparator implementations to use by tests on stdout, along with exit code expectations.

Index

Constants

View Source
const (
	// ExitCodeSuccess will ensure that the command effectively ran returned with exit code zero.
	ExitCodeSuccess = 0
	// ExitCodeSigkill verifies a container exited due to SIGKILL.
	ExitCodeSigkill = 137
	// ExitCodeGenericFail will verify that the command ran and exited with a non-zero error code.
	// This does NOT include timeouts, cancellation, or signals.
	ExitCodeGenericFail = -10
	// ExitCodeNoCheck does not enforce any check at all on the function.
	ExitCodeNoCheck = -11
	// ExitCodeTimeout verifies that the command was cancelled on timeout.
	ExitCodeTimeout = -12
	// ExitCodeSignaled verifies that the command has been terminated by a signal.
	ExitCodeSignaled = -13
)

Variables

This section is empty.

Functions

func All

func All(comparators ...test.Comparator) test.Comparator

All can be used as a parameter for expected.Output to group a set of comparators.

func Contains

func Contains(compare string, more ...string) test.Comparator

Contains can be used as a parameter for expected.Output and ensures a comparison string is found contained in the output.

func DoesNotContain

func DoesNotContain(compare string, more ...string) test.Comparator

DoesNotContain is to be used for expected.Output to ensure a comparison string is NOT found in the output.

func DoesNotMatch

func DoesNotMatch(reg *regexp.Regexp) test.Comparator

DoesNotMatch returns a comparator verifying the output does not match the provided regexp.

func Equals

func Equals(compare string) test.Comparator

Equals is to be used for expected.Output to ensure it is exactly the output.

func JSON

func JSON[T any](obj T, verifier func(T, tig.T)) test.Comparator

JSON allows to verify that the output can be marshalled into T, and optionally can be further verified by a provided method.

func Match

func Match(reg *regexp.Regexp) test.Comparator

Match is to be used for expected.Output to ensure we match a regexp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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