@@ -33,6 +33,7 @@ func TestDoWithDataAllFailed(t *testing.T) {
3333#9: test
3434#10: test`
3535 assert .Len (t , err , 10 )
36+ fmt .Println (err .Error ())
3637 assert .Equal (t , expectedErrorFormat , err .Error (), "retry error format" )
3738 assert .Equal (t , uint (45 ), retrySum , "right count of retry" )
3839}
@@ -88,16 +89,17 @@ func TestRetryIf(t *testing.T) {
8889}
8990
9091func TestRetryIf_ZeroAttempts (t * testing.T ) {
91- var retryCount uint
92+ var retryCount , onRetryCount uint
9293 err := Do (
9394 func () error {
9495 if retryCount >= 2 {
9596 return errors .New ("special" )
9697 } else {
98+ retryCount ++
9799 return errors .New ("test" )
98100 }
99101 },
100- OnRetry (func (n uint , err error ) { retryCount ++ }),
102+ OnRetry (func (n uint , err error ) { onRetryCount = n }),
101103 RetryIf (func (err error ) bool {
102104 return err .Error () != "special"
103105 }),
@@ -107,7 +109,7 @@ func TestRetryIf_ZeroAttempts(t *testing.T) {
107109 assert .Error (t , err )
108110
109111 assert .Equal (t , "special" , err .Error (), "retry error format" )
110- assert .Equal (t , uint ( 2 ), retryCount , "right count of retry" )
112+ assert .Equal (t , retryCount , onRetryCount + 1 , "right count of retry" )
111113}
112114
113115func TestZeroAttemptsWithError (t * testing.T ) {
0 commit comments