Skip to content

Commit

Permalink
cancel test for backoff strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jan 28, 2019
1 parent 6a8eb01 commit c065073
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions repeater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ func TestRepeatBackoffFailed(t *testing.T) {
assert.Equal(t, 1, called, "called 1 times")
}

func TestRepeatBackoffCanceled(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, time.Millisecond*450)
defer cancel()

called := 0
fun := func() error {
called++
return errors.New("some error")
}

err := New(strategy.NewBackoff(5, 2, true)).Do(ctx, fun)
assert.EqualError(t, err, "some error")
assert.Equal(t, 3, called)
}
func TestRepeatOnce(t *testing.T) {
e := errors.New("some error")
called := 0
Expand Down

0 comments on commit c065073

Please sign in to comment.