Merge pull request #5553 from TimeIncOSS/b-fix-retry-err-bug
helper/resource: Error shouldn't be returned in case of success
This commit is contained in:
commit
cadd0c5767
|
@ -21,6 +21,7 @@ func Retry(timeout time.Duration, f RetryFunc) error {
|
||||||
Refresh: func() (interface{}, string, error) {
|
Refresh: func() (interface{}, string, error) {
|
||||||
rerr := f()
|
rerr := f()
|
||||||
if rerr == nil {
|
if rerr == nil {
|
||||||
|
resultErr = nil
|
||||||
return 42, "success", nil
|
return 42, "success", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,14 @@ func TestRetry(t *testing.T) {
|
||||||
tries := 0
|
tries := 0
|
||||||
f := func() *RetryError {
|
f := func() *RetryError {
|
||||||
tries++
|
tries++
|
||||||
if tries == 1 {
|
if tries == 3 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return RetryableError(fmt.Errorf("error"))
|
return RetryableError(fmt.Errorf("error"))
|
||||||
}
|
}
|
||||||
|
|
||||||
err := Retry(2*time.Second, f)
|
err := Retry(10*time.Second, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue