errors

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailure is the base error class for all errors that represent failed
	// assertions when evaluating a test.
	ErrFailure = errors.New("assertion failed")
	// ErrTimeoutExceeded is an ErrFailure when a test's execution exceeds a
	// timeout length.
	ErrTimeoutExceeded = fmt.Errorf("%s: timeout exceeded", ErrFailure)
	// ErrNotEqual is an ErrFailure when an expected thing doesn't equal an
	// observed thing.
	ErrNotEqual = fmt.Errorf("%w: not equal", ErrFailure)
	// ErrIn is an ErrFailure when a thing unexpectedly appears in an
	// container.
	ErrIn = fmt.Errorf("%w: in", ErrFailure)
	// ErrNotIn is an ErrFailure when an expected thing doesn't appear in an
	// expected container.
	ErrNotIn = fmt.Errorf("%w: not in", ErrFailure)
	// ErrNoneIn is an ErrFailure when none of a list of elements appears in an
	// expected container.
	ErrNoneIn = fmt.Errorf("%w: none in", ErrFailure)
	// ErrUnexpectedError is an ErrFailure when an unexpected error has
	// occurred.
	ErrUnexpectedError = fmt.Errorf("%w: unexpected error", ErrFailure)
)
View Source
var (
	// ErrUnknownSourceType indicates that a From() function was called with an
	// unknown source parameter type.
	ErrUnknownSourceType = errors.New("unknown source argument type")
	// ErrUnknownSpec indicates that there was a test spec definition in a YAML
	// file that no plugin could parse.
	ErrUnknownSpec = errors.New("no plugin could parse spec definition")
	// ErrUnknownField indicates that there was an unknown field in the parsing
	// of a spec or scenario.
	ErrUnknownField = errors.New("unknown field")
	// ErrParse indicates a YAML definition is not valid
	ErrParse = errors.New("invalid YAML")
	// ErrExpectedMap indicates that we did not find an expected mapping
	// field
	ErrExpectedMap = fmt.Errorf(
		"%w: expected map field", ErrParse,
	)
	// ErrExpectedScalar indicates that we did not find an expected scalar
	// field
	ErrExpectedScalar = fmt.Errorf(
		"%w: expected scalar field", ErrParse,
	)
	// ErrExpectedSequence indicates that we did not find an expected
	// scalar field
	ErrExpectedSequence = fmt.Errorf(
		"%w: expected sequence field", ErrParse,
	)
	// ErrExpectedInt indicates that we did not find an expected integer
	// value
	ErrExpectedInt = fmt.Errorf(
		"%w: expected int value", ErrParse,
	)
	// ErrExpectedScalarOrMap indicates that we did not find an expected
	// scalar or map field
	ErrExpectedScalarOrMap = fmt.Errorf(
		"%w: expected scalar or map field", ErrParse,
	)
	// ErrExpectedScalarOrSequence indicates that we did not find an expected
	// scalar or sequence of scalars field
	ErrExpectedScalarOrSequence = fmt.Errorf(
		"%w: expected scalar or sequence of scalars field", ErrParse,
	)
	// ErrParseTimeout indicates that the timeout specification was not valid.
	ErrExpectedTimeout = fmt.Errorf(
		"%w: expected timeout specification", ErrParse,
	)
	// ErrParseWait indicates that the wait specification was not valid.
	ErrExpectedWait = fmt.Errorf(
		"%w: expected wait specification", ErrParse,
	)
	// ErrFileNotFound is returned when a file path does not exist for a
	// create/apply/delete target.
	ErrFileNotFound = fmt.Errorf(
		"%w: file not found", ErrParse,
	)
)
View Source
var (
	// RuntimeError is the base error class for all errors occurring during
	// runtime (and not during the parsing of a scenario or spec)
	RuntimeError = errors.New("runtime error")
	// ErrRequiredFixture is returned when a required fixture has not
	// been registered with the context.
	ErrRequiredFixture = fmt.Errorf(
		"%w: required fixture missing",
		RuntimeError,
	)
)

Functions

func ExpectedIntAt

func ExpectedIntAt(node *yaml.Node) error

ExpectedIntAt returns an ErrExpectedInt error annotated with the line/column of the supplied YAML node.

func ExpectedMapAt

func ExpectedMapAt(node *yaml.Node) error

ExpectedMapAt returns an ErrExpectedMap error annotated with the line/column of the supplied YAML node.

func ExpectedScalarAt

func ExpectedScalarAt(node *yaml.Node) error

ExpectedScalarAt returns an ErrExpectedScalar error annotated with the line/column of the supplied YAML node.

func ExpectedScalarOrMapAt added in v1.2.1

func ExpectedScalarOrMapAt(node *yaml.Node) error

ExpectedScalarOrMapAt returns an ErrExpectedScalarOrMap error annotated with the line/column of the supplied YAML node.

func ExpectedScalarOrSequenceAt

func ExpectedScalarOrSequenceAt(node *yaml.Node) error

ExpectedScalarOrSequenceAt returns an ErrExpectedScalarOrSequence error annotated with the line/column of the supplied YAML node.

func ExpectedSequenceAt

func ExpectedSequenceAt(node *yaml.Node) error

ExpectedSequenceAt returns an ErrExpectedSequence error annotated with the line/column of the supplied YAML node.

func ExpectedTimeoutAt

func ExpectedTimeoutAt(node *yaml.Node) error

ExpectedTimeoutAt returns an ErrExpectedTimeout error annotated with the line/column of the supplied YAML node.

func ExpectedWaitAt

func ExpectedWaitAt(node *yaml.Node) error

ExpectedWaitAt returns an ErrExpectedWait error annotated with the line/column of the supplied YAML node.

func FileNotFound

func FileNotFound(path string, node *yaml.Node) error

FileNotFound returns ErrFileNotFound for a given file path

func In added in v1.3.0

func In(element, container interface{}) error

In returns an ErrIn when a thing unexpectedly appears in a container.

func NoneIn

func NoneIn(elements, container interface{}) error

NoneIn returns an ErrNoneIn when none of a list of elements appears in an expected container.

func NotEqual

func NotEqual(exp, got interface{}) error

NotEqual returns an ErrNotEqual when an expected thing doesn't equal an observed thing.

func NotEqualLength

func NotEqualLength(exp, got int) error

NotEqualLength returns an ErrNotEqual when an expected length doesn't equal an observed length.

func NotIn

func NotIn(element, container interface{}) error

NotIn returns an ErrNotIn when an expected thing doesn't appear in an expected container.

func RequiredFixtureMissing

func RequiredFixtureMissing(name string) error

RequiredFixtureMissing returns an ErrRequiredFixture with the supplied fixture name

func TimeoutExceeded

func TimeoutExceeded(duration string, failure error) error

TimeoutExceeded returns an ErrTimeoutExceeded when a test's execution exceeds a timeout length. The optional failure parameter indicates a failed assertion that occurred before a timeout was reached.

func UnexpectedError

func UnexpectedError(err error) error

UnexpectedError returns an ErrUnexpectedError when a supplied error is not expected.

func UnknownFieldAt

func UnknownFieldAt(field string, node *yaml.Node) error

UnknownFieldAt returns an ErrUnknownField for a supplied field annotated with the line/column of the supplied YAML node.

func UnknownSourceType

func UnknownSourceType(source interface{}) error

UnknownSourceType returns an ErrUnknownSourceType error describing the supplied parameter type.

func UnknownSpecAt

func UnknownSpecAt(path string, node *yaml.Node) error

UnknownSpecAt returns an ErrUnknownSpec with the line/column of the supplied YAML node.

Types

This section is empty.

Jump to

Keyboard shortcuts

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