1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-12 16:52:29 +08:00

perf(retry): the error returned by the Retry function contains the last error (#315)

This commit is contained in:
残念
2025-06-23 11:04:54 +08:00
committed by GitHub
parent c176ba378e
commit a97d27c32e
3 changed files with 8 additions and 5 deletions

View File

@@ -15,14 +15,16 @@ func TestRetryFailed(t *testing.T) {
assert := internal.NewAssert(t, "TestRetryFailed")
var number int
customError := errors.New("error occurs")
increaseNumber := func() error {
number++
return errors.New("error occurs")
return customError
}
err := Retry(increaseNumber, RetryWithLinearBackoff(time.Microsecond*50))
assert.IsNotNil(err)
assert.Equal(errors.Is(err, customError), true)
assert.Equal(DefaultRetryTimes, number)
}