@@ -428,7 +428,8 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
428428 t .Run ("Happy" , func (t * testing.T ) {
429429 defer goleak .VerifyNone (t )
430430
431- counter := atomic .NewInt32 (0 )
431+ checkCounter := atomic .NewInt32 (0 )
432+ checkResultCounter := atomic .NewInt32 (0 )
432433
433434 res , ok , err := RunActionWithParallelCheckAndResult (
434435 context .Background (),
@@ -438,25 +439,30 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
438439 },
439440 func (ctx context.Context ) (res parallelisationCheckResult , ok bool ) {
440441 return parallelisationCheckResult {
441- checks : counter .Inc (),
442+ checks : checkCounter .Inc (),
442443 status : "healthy" ,
443444 }, true
444445 },
446+ func (_ parallelisationCheckResult ) {
447+ checkResultCounter .Inc ()
448+ },
445449 10 * time .Millisecond ,
446450 )
447451
448452 require .NoError (t , err )
449453 require .True (t , ok )
450454
451455 assert .GreaterOrEqual (t , res .checks , int32 (10 ))
452- assert .Equal (t , res .checks , counter .Load ())
456+ assert .Equal (t , res .checks , checkCounter .Load ())
453457 assert .Equal (t , "healthy" , res .status )
458+ assert .Equal (t , checkCounter .Load (), checkResultCounter .Load ())
454459 })
455460
456461 t .Run ("Check Fails With Reason" , func (t * testing.T ) {
457462 defer goleak .VerifyNone (t )
458463
459- counter := atomic .NewInt32 (0 )
464+ checkCounter := atomic .NewInt32 (0 )
465+ checkResultCounter := atomic .NewInt32 (0 )
460466 actionStarted := atomic .NewBool (false )
461467
462468 status := "adrien"
@@ -469,7 +475,7 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
469475 return DetermineContextError (ctx )
470476 },
471477 func (ctx context.Context ) (res parallelisationCheckResult , ok bool ) {
472- if n := counter .Inc (); n >= 5 {
478+ if n := checkCounter .Inc (); n >= 5 {
473479 return parallelisationCheckResult {
474480 checks : n ,
475481 status : status ,
@@ -481,6 +487,9 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
481487 }, true
482488 }
483489 },
490+ func (_ parallelisationCheckResult ) {
491+ checkResultCounter .Inc ()
492+ },
484493 5 * time .Millisecond ,
485494 )
486495
@@ -491,12 +500,14 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
491500 require .False (t , ok )
492501 assert .Equal (t , status , res .status )
493502 assert .Equal (t , int32 (5 ), res .checks )
494- assert .Equal (t , int32 (5 ), counter .Load ())
503+ assert .Equal (t , int32 (5 ), checkCounter .Load ())
504+ assert .Equal (t , checkCounter .Load (), checkResultCounter .Load ())
495505 })
496506 t .Run ("Action Error (no context cancel)" , func (t * testing.T ) {
497507 defer goleak .VerifyNone (t )
498508
499- counter := atomic .NewInt32 (0 )
509+ checkCounter := atomic .NewInt32 (0 )
510+ checkResultCounter := atomic .NewInt32 (0 )
500511 status := "abdel"
501512
502513 res , ok , err := RunActionWithParallelCheckAndResult (
@@ -507,10 +518,13 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
507518 },
508519 func (ctx context.Context ) (parallelisationCheckResult , bool ) {
509520 return parallelisationCheckResult {
510- checks : counter .Inc (),
521+ checks : checkCounter .Inc (),
511522 status : status ,
512523 }, true
513524 },
525+ func (_ parallelisationCheckResult ) {
526+ checkResultCounter .Inc ()
527+ },
514528 5 * time .Millisecond ,
515529 )
516530
@@ -520,7 +534,8 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
520534
521535 assert .Equal (t , status , res .status )
522536 assert .GreaterOrEqual (t , res .checks , int32 (1 ))
523- assert .Equal (t , res .checks , counter .Load ())
537+ assert .Equal (t , res .checks , checkCounter .Load ())
538+ assert .Equal (t , checkCounter .Load (), checkResultCounter .Load ())
524539 })
525540
526541 t .Run ("Context cancel" , func (t * testing.T ) {
@@ -529,7 +544,8 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
529544 ctx , cancel := context .WithTimeout (context .Background (), 100 * time .Millisecond )
530545 defer cancel ()
531546
532- counter := atomic .NewInt32 (0 )
547+ checkCounter := atomic .NewInt32 (0 )
548+ checkResultCounter := atomic .NewInt32 (0 )
533549 status := "kem"
534550
535551 res , ok , err := RunActionWithParallelCheckAndResult (
@@ -540,17 +556,22 @@ func TestRunActionWithParallelCheckAndResult(t *testing.T) {
540556 },
541557 func (ctx context.Context ) (parallelisationCheckResult , bool ) {
542558 return parallelisationCheckResult {
543- checks : counter .Inc (),
559+ checks : checkCounter .Inc (),
544560 status : status ,
545561 }, true
546562 },
563+ func (_ parallelisationCheckResult ) {
564+ checkResultCounter .Inc ()
565+ },
547566 5 * time .Millisecond ,
548567 )
549568
550569 require .Error (t , err )
551570 errortest .AssertError (t , err , commonerrors .ErrTimeout )
552571 assert .True (t , ok )
553572 assert .GreaterOrEqual (t , res .checks , int32 (1 ))
573+ assert .Equal (t , res .checks , checkCounter .Load ())
574+ assert .Equal (t , checkCounter .Load (), checkResultCounter .Load ())
554575 })
555576}
556577
0 commit comments