The documentation for EventuallyWithT states:
// If the condition is not met before waitFor, the collected errors of
// the last tick are copied to t.
However, it is possible to show that this is not the case with the following test:
func TestEventuallyWithTFalse(t *testing.T) {
mockT := new(CollectT)
var calledOnce bool
condition := func(collect *CollectT) {
if calledOnce {
time.Sleep(time.Second)
}
True(collect, false)
calledOnce = true
}
False(t, EventuallyWithT(mockT, condition, 100*time.Millisecond, 20*time.Millisecond))
Len(t, mockT.errors, 2)
}
This test fails because the errors do not get copied; there is a race condition condition between the condition-checking goroutine and the assertion's goroutine.
The documentation for EventuallyWithT states:
However, it is possible to show that this is not the case with the following test:
This test fails because the errors do not get copied; there is a race condition condition between the condition-checking goroutine and the assertion's goroutine.