You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(condition): EventuallyWith now supports require in condition (#90)
* fix(condition): in async testing, allow condition goroutine to exit
* allows condition to Goexit without exiting the whole assertion
* feat(condition): CollectT now distinguishes between FailNow() and Cancel()
* FailNow() exits the condition, Cancel() interrupts the whole
assertion
* regenerated code with examples and doc strings
* fixes#90
Follow-up PRs:
1. Update documentation and code examples
2. Enhance / better report to user in migration tool
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Copy file name to clipboardExpand all lines: docs/doc-site/api/condition.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -798,13 +798,23 @@ The supplied [CollectT](https://pkg.go.dev/github.com/go-openapi/testify/v2/asse
798
798
If the condition is not met before the timeout, the collected errors from the
799
799
last tick are copied to t.
800
800
801
-
Calling [CollectT.FailNow](https://pkg.go.dev/CollectT#FailNow) cancels the condition immediately and causes the assertion to fail.
801
+
Calling [CollectT.FailNow](https://pkg.go.dev/CollectT#FailNow) (directly, or transitively through [require](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#require) assertions)
802
+
fails the current tick only: the poller will retry on the next tick. This means
803
+
[require](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#require)-style assertions inside [EventuallyWith](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#EventuallyWith) behave naturally — they abort
804
+
the current evaluation and let the polling loop converge.
805
+
806
+
To abort the whole assertion immediately (e.g. when the condition can no longer
807
+
be expected to succeed), call [CollectT.Cancel](https://pkg.go.dev/CollectT#Cancel).
802
808
803
809
#### Concurrency
804
810
805
811
The condition function is never executed in parallel: only one goroutine executes it.
806
812
It may write to variables outside its scope without triggering race conditions.
807
813
814
+
The condition is wrapped in its own goroutine, so a call to [runtime.Goexit](https://pkg.go.dev/runtime#Goexit)
815
+
(e.g. via [require](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#require) assertions or [CollectT.FailNow](https://pkg.go.dev/CollectT#FailNow)) cleanly aborts only the
816
+
current tick.
817
+
808
818
{{% expand title="Examples" %}}
809
819
{{< tabs >}}
810
820
{{% tab title="Usage" %}}
@@ -824,6 +834,7 @@ It may write to variables outside its scope without triggering race conditions.
0 commit comments