@@ -15,12 +15,12 @@ import (
1515
1616// alwaysFail returns an Operation that always returns the given error.
1717func alwaysFail (err error ) retry.Operation {
18- return func () error { return err }
18+ return func (ctx context. Context ) error { return err }
1919}
2020
2121// countingOp returns an Operation that always fails and increments *count.
2222func countingOp (count * atomic.Int64 , err error ) retry.Operation {
23- return func () error {
23+ return func (ctx context. Context ) error {
2424 count .Add (1 )
2525 return err
2626 }
@@ -32,7 +32,7 @@ func TestDo_SucceedsFirstAttempt(t *testing.T) {
3232 t .Parallel ()
3333
3434 calls := 0
35- err := retry .Do (context .Background (), func () error {
35+ err := retry .Do (context .Background (), func (ctx context. Context ) error {
3636 calls ++
3737 return nil
3838 }, retry .WithMaxAttempts (5 ))
@@ -52,7 +52,7 @@ func TestDo_SucceedsAfterTransientErrors(t *testing.T) {
5252 var calls atomic.Int64
5353
5454 err := retry .Do (context .Background (),
55- func () error {
55+ func (ctx context. Context ) error {
5656 n := calls .Add (1 )
5757 if n < 4 {
5858 return transient
@@ -80,7 +80,7 @@ func TestDo_PermanentErrorStopsImmediately(t *testing.T) {
8080 calls := 0
8181
8282 err := retry .Do (context .Background (),
83- func () error {
83+ func (ctx context. Context ) error {
8484 calls ++
8585 return retry .Permanent (permanent )
8686 },
@@ -143,7 +143,7 @@ func TestDo_ContextCancellationStopsLoop(t *testing.T) {
143143 }()
144144
145145 err := retry .Do (ctx ,
146- func () error {
146+ func (ctx context. Context ) error {
147147 calls .Add (1 )
148148 return transient
149149 },
@@ -167,7 +167,7 @@ func TestDo_ContextAlreadyCancelledBeforeFirstAttempt(t *testing.T) {
167167
168168 var calls atomic.Int64
169169 err := retry .Do (ctx ,
170- func () error {
170+ func (ctx context. Context ) error {
171171 calls .Add (1 )
172172 return errors .New ("should not reach" )
173173 },
@@ -247,7 +247,7 @@ func TestDo_NotifierCalledOnEachRetry(t *testing.T) {
247247
248248 var calls atomic.Int64
249249 _ = retry .Do (context .Background (),
250- func () error {
250+ func (ctx context. Context ) error {
251251 if calls .Add (1 ) <= failures {
252252 return transient
253253 }
@@ -269,7 +269,7 @@ func TestDo_NotifierNotCalledOnImmediateSuccess(t *testing.T) {
269269
270270 var notifyCount atomic.Int64
271271 _ = retry .Do (context .Background (),
272- func () error { return nil },
272+ func (ctx context. Context ) error { return nil },
273273 retry .WithNotifier (func (err error , wait time.Duration ) {
274274 notifyCount .Add (1 )
275275 }),
@@ -284,7 +284,7 @@ func TestDo_NotifierNotCalledOnPermanentError(t *testing.T) {
284284
285285 var notifyCount atomic.Int64
286286 _ = retry .Do (context .Background (),
287- func () error { return retry .Permanent (errors .New ("perm" )) },
287+ func (ctx context. Context ) error { return retry .Permanent (errors .New ("perm" )) },
288288 retry .WithMaxAttempts (5 ),
289289 retry .WithInitialInterval (1 * time .Millisecond ),
290290 retry .WithNotifier (func (err error , wait time.Duration ) {
@@ -345,7 +345,7 @@ func TestDo_DefaultsAreApplied(t *testing.T) {
345345 defer cancel ()
346346
347347 _ = retry .Do (ctx ,
348- func () error {
348+ func (ctx context. Context ) error {
349349 if calls .Add (1 ) >= 2 {
350350 return nil
351351 }
0 commit comments