Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Must ¶
Must will keep retrying the given function f until the testing.TB passed to it does not fail or one of the following conditions is met:
- the timeout is reached
- the maximum number of attempts is reached
If f does not succed, Must will halt the test calling t.Fatalf. Must behaviour can be changed by passing options to it.
func Should ¶
Should will keep retrying the given function f until the testing.TB passed to it does not fail or one of the following conditions is met:
- the timeout is reached
- the maximum number of attempts is reached
If f does not succed, Should will fail the test calling t.Errorf. Should behaviour can be changed by passing options to it.
Types ¶
type Eventually ¶
type Eventually struct {
// contains filtered or unexported fields
}
func New ¶
func New(options ...Option) *Eventually
New creates a new Eventually with the given options. This can be useful if you want to reuse the same configuration for multiple functions. For example:
e := eventually.New(eventually.WithMaxAttempts(10))
The returned Eventually has the following defaults unless otherwise specified:
Timeout: 10 seconds Interval: 100 milliseconds MaxAttempts: 0 (unlimited)
If you don't need to reuse the same configuration, you can use the Must and Should functions directly.
func (*Eventually) Must ¶
func (e *Eventually) Must(t testing.TB, f func(t testing.TB))
Must will keep retrying the given function f until the testing.TB passed to it does not fail or one of the following conditions is met:
- the timeout is reached
- the maximum number of attempts is reached
If f does not succed, Must will halt the test calling t.Fatalf.
func (*Eventually) Should ¶
func (e *Eventually) Should(t testing.TB, f func(t testing.TB))
Should will keep retrying the given function f until the testing.TB passed to it does not fail or one of the following conditions is met:
- the timeout is reached
- the maximum number of attempts is reached
If f does not succed, Should will fail the test calling t.Errorf.
type Option ¶
type Option func(*Eventually)
Option is a function that can be used to configure an Eventually.
func WithInterval ¶
WithInterval sets the interval Eventually will wait between attempts.
func WithMaxAttempts ¶
WithMaxAttempts sets the maximum number of attempts an Eventually will make.
func WithTimeout ¶
WithTimeout sets the timeout for an Eventually.