Documentation
¶
Overview ¶
Package fi provides shorthands for testify patterns - "fi is short for testify"
Index ¶
- func CleanupF(t *testing.T, f func() error)
- func NoErrorF(f func() error, t assert.TestingT)
- func RequireConditionWithTimeout(t require.TestingT, comp assert.Comparison, timeout time.Duration, ...)
- func RequireReaderContains(t require.TestingT, r io.Reader, substr string, timeout time.Duration, ...)
- func SkipLongTest(t *testing.T)
- type Requirement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequireConditionWithTimeout ¶ added in v0.3.0
func RequireConditionWithTimeout(t require.TestingT, comp assert.Comparison, timeout time.Duration, messages ...string)
RequireConditionWithTimeout asserts a complex condition within the given timeout. messages optionally contains either the message if condition failed, or that message together with the message if timeout exceeded. Note that this serves a different use case and operates differently than require.Eventually or require.Condition. This assertion pairs well with checks like lang.ReaderContains or regexp.MatchReader which may take a long time to complete or run indefinitely.
func RequireReaderContains ¶ added in v0.3.0
func RequireReaderContains(t require.TestingT, r io.Reader, substr string, timeout time.Duration, readerLabel string)
RequireReaderContains asserts that substr appears is read by r within timeout
func SkipLongTest ¶
SkipLongTest skips the current test when -short is set
Types ¶
type Requirement ¶
type Requirement[T any] struct { // The value returned by Require if the check passes Val T Check func(t require.TestingT) }
Requirement associates checks with a value
func FileExists ¶ added in v0.2.1
func FileExists(path string) Requirement[string]
FileExists defines a requirement that the file exists (experimental)
func NoError ¶
func NoError[T any](val T, err error) Requirement[T]
NoError defines a requirement that the result of the function can be used, and the associated error is nil
func (Requirement[T]) Require ¶
func (r Requirement[T]) Require(t require.TestingT) T
Require returns the Requirement value if the Check doesn't fail the current test