Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Condition ¶
type Condition func() bool
A Condition is a function that returns true when a test condition is satisfied.
type EventualOpts ¶
type EventualOpts struct {
// contains filtered or unexported fields
}
EventualOpts defines a polling strategy for operations that must eventually succeed. A new EventualOpts must be provided for each invocation of Eventually (or call Reset on a previously completed set of options).
func NewEventualOpts ¶
func NewEventualOpts(interval, deadline time.Duration) *EventualOpts
NewEventualOpts constructs an EventualOpts instance with the provided polling interval and deadline. EventualOpts will perform randomized exponential backoff using the starting interval, and will stop polling (and therefore fail) after deadline time as elapsed from calling Eventually.
Note: we always backoff with a randomization of 0.5 (50%), a multiplier of 1.5, and a max interval of one minute.
func (EventualOpts) Eventually ¶
func (e EventualOpts) Eventually(t *testing.T, name string, cond Condition)
Eventually polls cond until it succeeds (returns true) or we exceed the deadline. Eventually performs backoff while polling cond.
name is printed as part of the test failure message when we exceed the deadline to help identify the test case failing. cond does not need to be thread-safe: it is only called from the current goroutine. cond itself can also fail the test early using t.Fatal.