Documentation
¶
Index ¶
- func Compare[T any](t test.TestingT, got, want T, gocmpOpts ...gocmp.Option) (test.TestingT, bool, string)
- func Eventually(ctx context.Context, t test.TestingT, check func(context.Context) error, ...) (test.TestingT, bool, string)
- func Not(t test.TestingT, result bool, msgAndArgs ...any) (test.TestingT, bool, string)
- func Panics(t test.TestingT, f func(), assertReason func(reason any) error) (tt test.TestingT, result bool, msg string)
- func ZeroValue[T comparable](t test.TestingT, v T) (test.TestingT, bool, string)
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 ¶
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)).
Types ¶
This section is empty.