mirror of
https://github.com/status-im/consul.git
synced 2025-02-13 14:16:35 +00:00
The current retry framework in testutil/testprc.WaitForResult uses a func() (bool, error) callback until it succeeds or times out. It captures the last error and returns it. if err := testutil.WaitForResult(t, func() (bool, error) { if err := foo(); err != nil { return false, err } ... return true, nil }); err != nil { t.Fatal(err) } This makes the test functions more complex than they need to be since both the boolean and the error indicate a success or a failure. The retry.Run framework uses a an approach similar to t.Run() from the testing framework. retry.Run(t, func(r *retry.R) { if err := foo(); err != nil { r.Fatal(err) } }) The behavior of the Run function is configurable so that different timeouts can be used for different tests.