Skip to content

Commit 2d7c85c

Browse files
committed
docs: clarify EventuallyWithTf callback vs failure message
The godoc examples implied format strings belong on the condition callback. Document that msg/args apply only on timeout. Fixes #1833
1 parent 12f8b56 commit 2d7c85c

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

assert/assertion_format.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
192192
// }()
193193
// assert.EventuallyWithTf(t, func(c *assert.CollectT) {
194194
// // add assertions as needed; any assertion failure will fail the current tick
195-
// assert.True(c, externalValue, "expected 'externalValue' to be true")
196-
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
195+
// assert.True(c, externalValue)
196+
// }, 10*time.Second, 1*time.Second, "externalValue was not true before timeout")
197+
//
198+
// The msg and args format the failure when the condition is never met; they are
199+
// not passed to the condition callback.
197200
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
198201
if h, ok := t.(tHelper); ok {
199202
h.Helper()

assert/assertion_forward.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,11 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor
374374
// }()
375375
// a.EventuallyWithTf(func(c *assert.CollectT) {
376376
// // add assertions as needed; any assertion failure will fail the current tick
377-
// assert.True(c, externalValue, "expected 'externalValue' to be true")
378-
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
377+
// assert.True(c, externalValue)
378+
// }, 10*time.Second, 1*time.Second, "externalValue was not true before timeout")
379+
//
380+
// The msg and args format the failure when the condition is never met; they are
381+
// not passed to the condition callback.
379382
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
380383
if h, ok := a.t.(tHelper); ok {
381384
h.Helper()

require/require.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,11 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF
459459
// }()
460460
// require.EventuallyWithTf(t, func(c *assert.CollectT) {
461461
// // add assertions as needed; any assertion failure will fail the current tick
462-
// require.True(c, externalValue, "expected 'externalValue' to be true")
463-
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
462+
// require.True(c, externalValue)
463+
// }, 10*time.Second, 1*time.Second, "externalValue was not true before timeout")
464+
//
465+
// The msg and args format the failure when the condition is never met; they are
466+
// not passed to the condition callback.
464467
func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
465468
if h, ok := t.(tHelper); ok {
466469
h.Helper()

require/require_forward.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,11 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w
375375
// }()
376376
// a.EventuallyWithTf(func(c *assert.CollectT) {
377377
// // add assertions as needed; any assertion failure will fail the current tick
378-
// assert.True(c, externalValue, "expected 'externalValue' to be true")
379-
// }, 10*time.Second, 1*time.Second, "error message %s", "formatted")
378+
// assert.True(c, externalValue)
379+
// }, 10*time.Second, 1*time.Second, "externalValue was not true before timeout")
380+
//
381+
// The msg and args format the failure when the condition is never met; they are
382+
// not passed to the condition callback.
380383
func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
381384
if h, ok := a.t.(tHelper); ok {
382385
h.Helper()

0 commit comments

Comments
 (0)