Documentation ¶
Index ¶
- Variables
- func AsCheckFunc[W any, G any](check func(W, G) error) func(W) CheckFunc[G]
- func DoesNotPanic(f func()) (err error)
- func Equal[T any](want, got T, opts ...cmp.Option) error
- func Equalf[T any](want, got T, msg string, args ...any) error
- func Expect(t *testing.T, errs ...error)
- func HasNoError[T any](_ T, err error) error
- func IgnoreFields[T any](fields ...string) cmp.Option
- func IsEmptySlice[T any](slice []T) error
- func IsError(want, got error) error
- func IsErrorf(want, got error, msg string, args ...any) error
- func IsNilPointer[T any](ptr *T) error
- func IsNilPointerf[T any](ptr *T, msg string, args ...any) error
- func IsNotEmptySlice[T any](slice []T) error
- func IsNotNilPointer[T any](ptr *T) error
- func IsNotNilPointerf[T any](ptr *T, msg string, args ...any) error
- func IsNotZero[T any](have T, opts ...cmp.Option) error
- func IsNotZerof[T any](have T, msg string, args ...any) error
- func IsSamePointer[T any](want, got *T) error
- func IsSamePointerf[T any](want, got *T, msg string, args ...any) error
- func IsZero[T any](obj T) error
- func NewTestContext() (context.Context, context.CancelFunc)
- func NoError(err error) error
- func NoErrorf(err error, msg string, args ...any) error
- func NotEqual[T any](want, got T, opts ...cmp.Option) error
- func NotEqualf[T any](want, got T, msg string, args ...any) error
- func PointerTo[T any](obj T) *T
- func ReadChannel[T any](ctx context.Context, ch <-chan T) (T, error)
- func Require(t *testing.T, errs ...error)
- func ShouldPanic(f func()) error
- func SliceContains[T comparable](want T, slice []T) error
- func SliceDoesNotContain[T comparable](want T, slice []T) error
- func SliceHasLength[T any](want int, slice []T) error
- func TestContext(timeout time.Duration) (context.Context, context.CancelFunc)
- type CheckFunc
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = 20 * time.Second
DefaultTimeout is the default timeout given to test contexts.
var ErrChannelClosed = errors.New("channel was closed")
var ErrReadTimeout = errors.New("context timed out while reading channel")
var IgnoreUnexported = cmpopts.IgnoreUnexported
Functions ¶
func AsCheckFunc ¶
AsCheckFunc transforms a basic want/got checker into a CheckFunc generator.
func DoesNotPanic ¶
func DoesNotPanic(f func()) (err error)
func HasNoError ¶
HasNoError is a CheckFunc that asserts the absence of an error.
func IsEmptySlice ¶
func IsError ¶
IsError checks that the returned error (got) is the one expected (want). If want is nil, it behaves the same as NoError.
func IsNilPointer ¶
IsNilPointer returns an error if given pointer is not nil.
func IsNilPointerf ¶
IsNilPointerf returns an error if given pointer is not nil.
func IsNotEmptySlice ¶
func IsNotNilPointer ¶
IsNotNilPointer returns an error if given pointer is nil.
func IsNotNilPointerf ¶
IsNotNilPointer returns an error if given pointer is nil.
func IsNotZerof ¶
IsNotZerof returns an error with a custom message if the value is not a zero value.
func IsSamePointer ¶
func NewTestContext ¶
func NewTestContext() (context.Context, context.CancelFunc)
NewTestContext returns a context with a sensible default timeout for tests.
func ShouldPanic ¶
func ShouldPanic(f func()) error
ShouldPanic returns an error if given function does not panic when called.
func SliceContains ¶
func SliceContains[T comparable](want T, slice []T) error
func SliceDoesNotContain ¶
func SliceDoesNotContain[T comparable](want T, slice []T) error
func SliceHasLength ¶
func TestContext ¶
TestContext is a short wrapper around context.WithTimeout.