Skip to content

Commit

Permalink
Merge pull request #5553 from TimeIncOSS/b-fix-retry-err-bug
Browse files Browse the repository at this point in the history
helper/resource: Error shouldn't be returned in case of success
  • Loading branch information
phinze committed Mar 10, 2016
2 parents 2dc1c02 + 034287f commit cadd0c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions helper/resource/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func Retry(timeout time.Duration, f RetryFunc) error {
Refresh: func() (interface{}, string, error) {
rerr := f()
if rerr == nil {
resultErr = nil
return 42, "success", nil
}

Expand Down
4 changes: 2 additions & 2 deletions helper/resource/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ func TestRetry(t *testing.T) {
tries := 0
f := func() *RetryError {
tries++
if tries == 1 {
if tries == 3 {
return nil
}

return RetryableError(fmt.Errorf("error"))
}

err := Retry(2*time.Second, f)
err := Retry(10*time.Second, f)
if err != nil {
t.Fatalf("err: %s", err)
}
Expand Down

0 comments on commit cadd0c5

Please sign in to comment.