errors

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

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)
	// 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,
	)
	// 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 (
	// ErrRuntime is the base error class for all errors occurring during
	// runtime (and not during the parsing of a scenario or spec)
	ErrRuntime = 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",
		ErrRuntime,
	)
	// ErrTimeout is returned when a context deadline was exceeeded, a signal
	// was killed in an exec.Spec.Run() call or an expected test spec did not
	// complete in some allocated amount of time.
	ErrTimeout = fmt.Errorf(
		"%w: timeout exceeded",
		ErrRuntime,
	)
)

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 ExpectedScalarOrSequenceAt added in v1.10.1

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 added in v1.2.0

func ExpectedTimeoutAt(node *yaml.Node) error

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

func ExpectedWaitAt added in v1.9.0

func ExpectedWaitAt(node *yaml.Node) error

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

func FileNotFound added in v1.8.1

func FileNotFound(path string) error

FileNotFound returns ErrFileNotFound for a given file path

func NoneIn added in v1.9.0

func NoneIn(elements, container interface{}) error

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

func NotEqual added in v1.9.0

func NotEqual(exp, got interface{}) error

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

func NotEqualLength added in v1.9.0

func NotEqualLength(exp, got int) error

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

func NotIn added in v1.9.0

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 added in v1.9.0

func TimeoutExceeded(duration string) error

TimeoutExceeded returns an ErrTimeoutExceeded when a test's execution exceeds a timeout length.

func UnexpectedError added in v1.9.3

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 added in v1.4.0

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

type RuntimeErrors

type RuntimeErrors struct {
	// contains filtered or unexported fields
}

RuntimeErrors is a collection of zero or more errors resulting from Run() calls. It implements the error interface.

func NewRuntimeErrors

func NewRuntimeErrors() *RuntimeErrors

func (*RuntimeErrors) AppendIf

func (r *RuntimeErrors) AppendIf(err error)

AppendIf appends the supplied error to the RuntimeErrors collection of errors if the supplied error is not nil.

func (*RuntimeErrors) Empty added in v1.4.0

func (r *RuntimeErrors) Empty() bool

Empty returns true if the RuntimeErrors contains no errors.

func (*RuntimeErrors) Error

func (r *RuntimeErrors) Error() string

Error implements the error interface

func (*RuntimeErrors) Has added in v1.7.1

func (r *RuntimeErrors) Has(target error) bool

Has checks the RuntimeErrors has at least one contained error that matches the supplied error type target.

func (*RuntimeErrors) String added in v1.7.2

func (r *RuntimeErrors) String() string

String satisfies the Stringer interface

Jump to

Keyboard shortcuts

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