MCPcopy Index your code
hub / github.com/expr-lang/expr / Eventually

Function Eventually

internal/testify/assert/assertions.go:1869–1896  ·  view source on GitHub ↗

Eventually asserts that given condition will be met in waitFor time, periodically checking target function each tick. assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)

(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1867//
1868// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond)
1869func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
1870 if h, ok := t.(tHelper); ok {
1871 h.Helper()
1872 }
1873
1874 ch := make(chan bool, 1)
1875
1876 timer := time.NewTimer(waitFor)
1877 defer timer.Stop()
1878
1879 ticker := time.NewTicker(tick)
1880 defer ticker.Stop()
1881
1882 for tick := ticker.C; ; {
1883 select {
1884 case <-timer.C:
1885 return Fail(t, "Condition never satisfied", msgAndArgs...)
1886 case <-tick:
1887 tick = nil
1888 go func() { ch <- condition() }()
1889 case v := <-ch:
1890 if v {
1891 return true
1892 }
1893 tick = ticker.C
1894 }
1895 }
1896}
1897
1898// CollectT implements the TestingT interface and collects all errors.
1899type CollectT struct {

Callers 6

EventuallyFunction · 0.92
EventuallyfFunction · 0.70
TestEventuallyFalseFunction · 0.70
TestEventuallyTrueFunction · 0.70
TestEventuallyTimeoutFunction · 0.70
EventuallyMethod · 0.70

Calls 2

FailFunction · 0.70
HelperMethod · 0.45

Tested by 3

TestEventuallyFalseFunction · 0.56
TestEventuallyTrueFunction · 0.56
TestEventuallyTimeoutFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…