check

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare[T any](t test.TestingT, got, want T, gocmpOpts ...gocmp.Option) (test.TestingT, bool, string)

Compare checks if two values are equal using go-cmp. This is usually used like test.Assert(check.Compare(t, got, want)).

func Eventually

func Eventually(ctx context.Context, t test.TestingT, check func(context.Context) error, timeBetweenRetries time.Duration) (test.TestingT, bool, string)

Eventually repeatedly executes a check function until it succeeds or the context expires.

The function continuously retries the check until one of the following occurs: - The check function returns nil (success) - The provided context is canceled or times out

This is typically used for asynchronous tests that may take time to reach the desired state.

Example: test.Assert(check.Eventually(ctx, test.Context(t), func(ctx context.Context) error {
	// ...
}, time.Millisecond*100))

func Not

func Not(t test.TestingT, result bool, msgAndArgs ...any) (test.TestingT, bool, string)

Not inverts the result of a boolean test check.

This function is typically used with other check functions to negate their results. When used with other check functions, it will invert their pass/fail result.

Example:

test.Assert(check.Not(check.Panics(t, func() { /* code that should not panic */ }, nil)))

func Panics

func Panics(t test.TestingT, f func(), assertReason func(reason any) error) (tt test.TestingT, result bool, msg string)

Panics checks if a function panics. The `f` argument is the function to be tested for panic, `assertReason` is an optional function that can be used to assert on the recovered panic value. If `f` panics, and `assertReason` is provided and returns an error, Panics will return false and the error message. This is usually used like test.Assert(check.Panics(t, func(){panic("boom")}, nil)).

func ZeroValue

func ZeroValue[T comparable](t test.TestingT, v T) (test.TestingT, bool, string)

ZeroValue checks if a value is equal to the zero value of its type. This is usually used like test.Assert(check.ZeroValue(t, 0, nil)).

Types

This section is empty.

Jump to

Keyboard shortcuts

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