-
Notifications
You must be signed in to change notification settings - Fork 887
chore: add testutil.Eventually and friends #3389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some comments/suggestions but nice work!
// the case in order to avoid potentially waiting forever. | ||
// | ||
// condition is not run in a goroutine; use the provided | ||
// context argument for cancellation if required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great docs ❤️!
Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
case <-ctx.Done(): | ||
assert.NoError(t, ctx.Err(), "Eventually timed out") | ||
return false | ||
case <-tick: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My head must've been background processing this PR review, just realized there's a race here between tick
s and ctx.Done()
, we should add an additional check for ctx.Done()
after receiving the tick, otherwise we may run the condition as many additional times as the go runtime decides to prioritize the tick
.
This PR adds a
testutil
function aimed to replacerequire.Eventually
.Should be useful in conjunction with #3381
Before:
After: