@@ -215,7 +215,6 @@ func TestHandle(t *testing.T) {
215
215
& mockCheck {
216
216
name : "Test1" ,
217
217
result : CheckResult {
218
- Name : "Test1" ,
219
218
Allowed : false ,
220
219
Causes : []Cause {
221
220
{
@@ -305,7 +304,6 @@ func TestHandle(t *testing.T) {
305
304
& mockCheck {
306
305
name : "Test1" ,
307
306
result : CheckResult {
308
- Name : "Test1" ,
309
307
Allowed : false ,
310
308
Error : true ,
311
309
Causes : []Cause {
@@ -322,7 +320,6 @@ func TestHandle(t *testing.T) {
322
320
& mockCheck {
323
321
name : "Test2" ,
324
322
result : CheckResult {
325
- Name : "Test2" ,
326
323
Allowed : false ,
327
324
Causes : []Cause {
328
325
{
@@ -338,7 +335,6 @@ func TestHandle(t *testing.T) {
338
335
& mockCheck {
339
336
name : "Test3" ,
340
337
result : CheckResult {
341
- Name : "Test3" ,
342
338
Allowed : true ,
343
339
},
344
340
},
@@ -442,7 +438,6 @@ func (c *cancellableCheck) Run(ctx context.Context) CheckResult {
442
438
case <- ctx .Done ():
443
439
c .cancelled = true
444
440
return CheckResult {
445
- Name : c .name ,
446
441
Allowed : false ,
447
442
Error : true ,
448
443
Causes : []Cause {
@@ -453,7 +448,6 @@ func (c *cancellableCheck) Run(ctx context.Context) CheckResult {
453
448
}
454
449
case <- time .After (c .delay ):
455
450
return CheckResult {
456
- Name : c .name ,
457
451
Allowed : true ,
458
452
}
459
453
}
@@ -573,7 +567,6 @@ func TestRun_SingleCheckerSingleCheck(t *testing.T) {
573
567
& mockCheck {
574
568
name : "check1" ,
575
569
result : CheckResult {
576
- Name : "check1" ,
577
570
Allowed : true ,
578
571
},
579
572
},
@@ -597,14 +590,12 @@ func TestRun_MultipleCheckersMultipleChecks(t *testing.T) {
597
590
& mockCheck {
598
591
name : "c1-check1" ,
599
592
result : CheckResult {
600
- Name : "c1-check1" ,
601
593
Allowed : true ,
602
594
},
603
595
},
604
596
& mockCheck {
605
597
name : "c1-check2" ,
606
598
result : CheckResult {
607
- Name : "c1-check2" ,
608
599
Allowed : false ,
609
600
},
610
601
},
@@ -615,7 +606,6 @@ func TestRun_MultipleCheckersMultipleChecks(t *testing.T) {
615
606
& mockCheck {
616
607
name : "c2-check1" ,
617
608
result : CheckResult {
618
- Name : "c2-check1" ,
619
609
Error : true ,
620
610
},
621
611
},
@@ -663,7 +653,7 @@ func (c *delayedCheck) Run(ctx context.Context) CheckResult {
663
653
c .mu .Unlock ()
664
654
}
665
655
666
- return CheckResult {Name : c . name , Allowed : true }
656
+ return CheckResult {Allowed : true }
667
657
}
668
658
669
659
func TestRun_ChecksRunInParallel (t * testing.T ) {
@@ -766,11 +756,11 @@ func TestRun_ContextCancellation(t *testing.T) {
766
756
check := & contextAwareCheck {
767
757
name : "cancellable-check" ,
768
758
onCancel : func () CheckResult {
769
- return CheckResult {Name : "cancelled" , Error : true }
759
+ return CheckResult {Error : true }
770
760
},
771
761
onTimeout : func () CheckResult {
772
762
close (completed )
773
- return CheckResult {Name : "completed" , Allowed : true }
763
+ return CheckResult {Allowed : true }
774
764
},
775
765
}
776
766
@@ -870,7 +860,6 @@ func TestRun_LargeNumberOfCheckersAndChecks(t *testing.T) {
870
860
checks [j ] = & mockCheck {
871
861
name : fmt .Sprintf ("checker%d-check%d" , checkerIndex , checkIndex ),
872
862
result : CheckResult {
873
- Name : fmt .Sprintf ("checker%d-check%d" , checkerIndex , checkIndex ),
874
863
Allowed : true ,
875
864
},
876
865
}
@@ -906,7 +895,6 @@ func TestRun_ErrorHandlingInChecks(t *testing.T) {
906
895
errorCheck := & mockCheck {
907
896
name : "error-check" ,
908
897
result : CheckResult {
909
- Name : "error-check" ,
910
898
Error : true ,
911
899
Causes : []Cause {
912
900
{
@@ -926,13 +914,15 @@ func TestRun_ErrorHandlingInChecks(t *testing.T) {
926
914
assert .Len (t , resultsOrderedByCheckerAndCheck , 1 , "expected results for 1 checker" )
927
915
assert .Len (t , resultsOrderedByCheckerAndCheck [0 ], 1 , "expected 1 result from the checker" )
928
916
929
- wantErrorCheckResult := CheckResult {
930
- Name : "error-check" ,
931
- Error : true ,
932
- Causes : []Cause {
933
- {
934
- Message : "simulated error in check" ,
935
- Field : "spec.errorField" ,
917
+ wantErrorCheckResult := namedResult {
918
+ Name : "error-check" ,
919
+ CheckResult : CheckResult {
920
+ Error : true ,
921
+ Causes : []Cause {
922
+ {
923
+ Message : "simulated error in check" ,
924
+ Field : "spec.errorField" ,
925
+ },
936
926
},
937
927
},
938
928
}
@@ -971,7 +961,6 @@ func TestRun_PanicHandlingInChecks(t *testing.T) {
971
961
normalCheck := & mockCheck {
972
962
name : "normal-check" ,
973
963
result : CheckResult {
974
- Name : "normal-check" ,
975
964
Allowed : true ,
976
965
},
977
966
}
@@ -989,17 +978,21 @@ func TestRun_PanicHandlingInChecks(t *testing.T) {
989
978
assert .Len (t , resultsOrderedByCheckerAndCheck , 1 , "expected results for 1 checker" )
990
979
assert .Len (t , resultsOrderedByCheckerAndCheck [0 ], 2 , "expected 2 results from the checker" )
991
980
992
- wantNormalCheckResult := CheckResult {
993
- Name : "normal-check" ,
994
- Allowed : true ,
981
+ wantNormalCheckResult := namedResult {
982
+ Name : "normal-check" ,
983
+ CheckResult : CheckResult {
984
+ Allowed : true ,
985
+ },
995
986
}
996
- wantPanicCheckResult := CheckResult {
997
- Name : "panicking-check" ,
998
- Error : true ,
999
- Causes : []Cause {
1000
- {
1001
- Message : "internal error (panic): simulated panic in check" ,
1002
- Field : "" ,
987
+ wantPanicCheckResult := namedResult {
988
+ Name : "panicking-check" ,
989
+ CheckResult : CheckResult {
990
+ Error : true ,
991
+ Causes : []Cause {
992
+ {
993
+ Message : "internal error (panic): simulated panic in check" ,
994
+ Field : "" ,
995
+ },
1003
996
},
1004
997
},
1005
998
}
@@ -1021,7 +1014,6 @@ func TestRun_ZeroChecksFromChecker(t *testing.T) {
1021
1014
& mockCheck {
1022
1015
name : "check1" ,
1023
1016
result : CheckResult {
1024
- Name : "check1" ,
1025
1017
Allowed : true ,
1026
1018
},
1027
1019
},
0 commit comments