Conversation
This changeset adds the `assert.Consistently` and it's associated functions to assert that a condition is true over the entire period of `waitFor`. This is useful when testing the behavior of asynchronous functions. Closes stretchr#1087
a11e144 to
5e6e95d
Compare
|
I don't want more uses of |
|
We already have |
@dolmen, curious, what are the issues with |
|
|
Make sense, what would be the reversed condition asserter ? NotNever ? The name would be strange. But using another name that is not the opposite of Never would be strange no? |
|
In my opinion the opposite of
I don't have a strong preference on naming here. |
| go func() { ch <- condition() }() | ||
| case v := <-ch: | ||
| if !v { | ||
| return Fail(t, "Condition never satisfied", msgAndArgs...) |
There was a problem hiding this comment.
nit: not sure if this is the right error message. To me, "Condition never satisfied" makes sense in the case of Eventually. The term never is not applicable in the context of Consistently.
| }() | ||
| case errs := <-ch: | ||
| if len(errs) > 0 { | ||
| return Fail(t, "Condition never satisfied", msgAndArgs...) |
There was a problem hiding this comment.
add the errors to t first before calling Fail. Reference: https://github.com/stretchr/testify/blob/master/assert/assertions.go#L2017
|
If we are happy with I missed the fact that |
Got it. So you would like to get rid of |
My only concern here is that using |
|
I was reluctant to add About the implementation, I think it's a bit early because we are not yet done with |
Summary
This changeset adds the
assert.Consistentlyand it's associated functions to assert that a condition is true over the entire period ofwaitFor. This is useful when testing the behavior of asynchronous functions.Changes
assert.Consistentlychecks that a provided function is true for the entirety ofwaitForassert.Consistentlyfchecks that a provided function is true for the entirety ofwaitForand allows for formatting the error messageassert.ConsistentlyWithTchecks that a provided function that accepts atesting.Tis true for the entirety ofwaitForassert.ConsistentlyWithTfchecks that a provided function that accepts atesting.Tis true for the entirety ofwaitForand allows for formatting the error messageMotivation
See: #1087 (comment)
Related issues
Closes #1087