diff --git a/assert/assertion_format.go b/assert/assertion_format.go index a19a89279..1da869c87 100644 --- a/assert/assertion_format.go +++ b/assert/assertion_format.go @@ -185,14 +185,15 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // assert.EventuallyWithTf(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { diff --git a/assert/assertion_forward.go b/assert/assertion_forward.go index cd2a86061..096a532dc 100644 --- a/assert/assertion_forward.go +++ b/assert/assertion_forward.go @@ -342,14 +342,15 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // a.EventuallyWithT(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { @@ -367,14 +368,15 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // a.EventuallyWithTf(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { diff --git a/assert/assertions.go b/assert/assertions.go index 166f63726..e49ff00d2 100644 --- a/assert/assertions.go +++ b/assert/assertions.go @@ -2090,14 +2090,15 @@ func (c *CollectT) failed() bool { // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // assert.EventuallyWithT(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { diff --git a/require/require.go b/require/require.go index 652871f2e..365ca81d0 100644 --- a/require/require.go +++ b/require/require.go @@ -424,14 +424,15 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // require.EventuallyWithT(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// require.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// require.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { @@ -452,14 +453,15 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // require.EventuallyWithTf(t, func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// require.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// require.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { diff --git a/require/require_forward.go b/require/require_forward.go index edac147ef..4c0f5f5a8 100644 --- a/require/require_forward.go +++ b/require/require_forward.go @@ -343,14 +343,15 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // a.EventuallyWithT(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false") func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { @@ -368,14 +369,15 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w // If the condition is not met before waitFor, the collected errors of // the last tick are copied to t. // -// externalValue := false +// var externalValue int32 // go func() { // time.Sleep(8*time.Second) -// externalValue = true +// atomic.StoreInt32(&externalValue, 1) // }() // a.EventuallyWithTf(func(c *assert.CollectT) { // // add assertions as needed; any assertion failure will fail the current tick -// assert.True(c, externalValue, "expected 'externalValue' to be true") +// isSet := atomic.LoadInt32(&externalValue) == 1 +// assert.True(c, isSet, "expected 'externalValue' to be true") // }, 10*time.Second, 1*time.Second, "error message %s", "formatted") func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok {