Documentation
¶
Index ¶
- func AssertErrorIs(t *testing.T, expected, actual error, message string)
- func CheckError(t *testing.T, name string, expectedErr error, actualErr error)
- func CheckErrors(t *testing.T, name string, expectedErrs []error, actualErr error)
- func CheckOutput(t *testing.T, name string, expected any, actual any)
- func CheckOutputWithError(t *testing.T, name string, expected any, expectedErr error, actual any, ...)
- type ExpectedOneOfErr
- type FileData
- type ParallelRunner
- type ParallelRunners
- type StrError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertErrorIs ¶
AssertErrorIs asserts actual contains expected via errors.Is(). Special handling for testutils.ExpectedOneOfErr: succeeds if *any* listed error matches.
Usage example:
var errs testutils.ExpectedOneOfErr errs = append(errs, ErrInvalidEmail, ErrMissingField) testutils.AssertErrorIs(t, errs, apiErr, "should include validation error")
func CheckErrors ¶
func CheckOutputWithError ¶
func CheckOutputWithError(t *testing.T, name string, expected any, expectedErr error, actual any, actualErr error, )
CheckOutputWithError verifies both output values and returned errors produced by a test case.
Special handling:
- If expectedErr is nil, any actual error fails the test.
- If expectedErr is a StrError, comparison allows either:
- errors.Is match, OR
- substring match of the error message.
- Otherwise, strict errors.Is comparison is required.
Types ¶
type ExpectedOneOfErr ¶
type ExpectedOneOfErr []error
ExpectedOneOfErr is a testutils wrapper for multiple errors that signals AssertErrorIs should check if *any* contained error matches the actual error. Enables flexible multi-error assertions.
func (ExpectedOneOfErr) Error ¶
func (e ExpectedOneOfErr) Error() string
type ParallelRunner ¶
type ParallelRunners ¶
type ParallelRunners[C any] []ParallelRunner[C]
type StrError ¶
type StrError struct {
// contains filtered or unexported fields
}
StrError is a marker error type used in tests to indicate that an error should primarily be compared by its string content.
Unlike ordinary errors that rely strictly on errors.Is matching, StrError allows fallback comparison via substring matching of the error message. This is useful when:
- the concrete error type is unstable or wrapped differently
- dynamic context is added to the error
- only the semantic message matters for the test
Test-helpers interpret this type as a signal that textual comparison is acceptable when strict error identity does not match.
func StringError ¶
StringError creates a StrError from a plain string.
Instead of asserting exact error identity, the testing utilities will allow message-based comparison when this marker type is used.