testify icon indicating copy to clipboard operation
testify copied to clipboard

Check condition immediately in *.Eventually

Open cszczepaniak opened this issue 2 years ago • 0 comments

Summary

assert.Eventually waits for the tick interval before doing the first check of the condition. In a lot of cases, the condition might be true immediately, so it would be helpful to check it right away..

Changes

  • Return early from assert.Eventually if the condition is already met. This will also affect require.Eventually.

Motivation

This change avoids unnecessary waiting and allocations if the condition is true immediately -- it precludes us needing to set up a ticker, timer, and channel. This can save a lot of time when running tests repeatedly.

Related issues

cszczepaniak avatar Dec 11 '21 15:12 cszczepaniak