hashicorp/consul — pull request #136 by tiwilliam (2014-05-07 00:51:40+00:00)
Title: WIP: Proof of concept using `WaitForResult` in tests

This is an alternative solution to using sleeps in test. `WaitForResult` will retry the test call every 10ms and timeout after 5s. A sample test call look like this:

testutil.WaitForResult(func() (bool, error) {
value, err := SomethingToTest()
return value == "correct", err
}, func(err error) {
t.Fatalf("Something went wrong: %v", err)
})