Skip to content

Commit da9e5f4

Browse files
committed
feat(condition): regenerated code with examples and doc strings
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 1c5ae8c commit da9e5f4

File tree

7 files changed

+85
-4
lines changed

7 files changed

+85
-4
lines changed

assert/assert_assertions.go

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assert/assert_assertions_test.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assert/assert_format_test.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/doc-site/api/condition.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,13 +798,23 @@ The supplied [CollectT](https://pkg.go.dev/github.com/go-openapi/testify/v2/asse
798798
If the condition is not met before the timeout, the collected errors from the
799799
last tick are copied to t.
800800

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).
802808

803809
#### Concurrency
804810

805811
The condition function is never executed in parallel: only one goroutine executes it.
806812
It may write to variables outside its scope without triggering race conditions.
807813

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+
808818
{{% expand title="Examples" %}}
809819
{{< tabs >}}
810820
{{% tab title="Usage" %}}
@@ -824,6 +834,7 @@ It may write to variables outside its scope without triggering race conditions.
824834
)
825835
success: func(c *CollectT) { True(c,true) }, 100*time.Millisecond, 20*time.Millisecond
826836
failure: func(c *CollectT) { False(c,true) }, 100*time.Millisecond, 20*time.Millisecond
837+
failure: func(c *CollectT) { c.Cancel() }, 100*time.Millisecond, 20*time.Millisecond
827838
```
828839
{{< /tab >}}
829840
{{% tab title="Testable Examples (assert)" %}}
@@ -924,7 +935,7 @@ func main() {
924935
|--|--|
925936
| [`assertions.EventuallyWith[C CollectibleConditioner](t T, condition C, timeout time.Duration, tick time.Duration, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#EventuallyWith) | internal implementation |
926937

927-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#EventuallyWith](https://github.com/go-openapi/testify/blob/master/internal/assertions/condition.go#L253)
938+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#EventuallyWith](https://github.com/go-openapi/testify/blob/master/internal/assertions/condition.go#L264)
928939
{{% /tab %}}
929940
{{< /tabs >}}
930941

require/require_assertions.go

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

require/require_assertions_test.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

require/require_format_test.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)