// TestRetryFuncError tests an error inside the retried func. func TestRetryFuncError(t *testing.T) { assert := audit.NewTestingAssertion(t, true) err := timex.Retry(func() (bool, error) { return false, errors.New("ouch") }, timex.ShortAttempt()) assert.ErrorMatch(err, "ouch") }
// TestRetrySuccess tests a successful retry. func TestRetrySuccess(t *testing.T) { assert := audit.NewTestingAssertion(t, true) count := 0 err := timex.Retry(func() (bool, error) { count++ return count == 5, nil }, timex.ShortAttempt()) assert.Nil(err) assert.Equal(count, 5) }