@@ -913,9 +913,9 @@ func TestScanProducesRemediationsAndLabels(t *testing.T) {
913913 Namespace : f .OperatorNamespace ,
914914 },
915915 Spec : compv1alpha1.TailoredProfileSpec {
916- Title : "TestScanProducesRemediationsAndLabels" ,
917- Description : "TestScanProducesRemediationsAndLabels" ,
918- Extends : "ocp4-moderate " ,
916+ Title : t . Name () ,
917+ Description : t . Name () ,
918+ Extends : "ocp4-e8 " ,
919919 },
920920 }
921921
@@ -981,18 +981,31 @@ func TestScanProducesRemediationsAndLabels(t *testing.T) {
981981 if len (checkList .Items ) == 0 {
982982 t .Fatal ("expected at least one check result" )
983983 }
984- // Use the first check to verify labels are working correctly
985- firstCheck := checkList .Items [0 ]
986- // Verify all required labels are present
987- labelsToVerify := []string {
988- compv1alpha1 .SuiteLabel ,
989- compv1alpha1 .ComplianceScanLabel ,
984+ // Expected scan name is binding name + profile name
985+ expectedScanName := bindingName + "-" + tpName
986+ // Verify all required labels are present on every check result
987+ // For some labels we can verify the exact value
988+ labelsWithValues := map [string ]string {
989+ compv1alpha1 .SuiteLabel : bindingName ,
990+ compv1alpha1 .ComplianceScanLabel : expectedScanName ,
991+ }
992+ // For other labels we just verify they are present (non-empty)
993+ labelsPresenceOnly := []string {
990994 compv1alpha1 .ComplianceCheckResultSeverityLabel ,
991995 compv1alpha1 .ComplianceCheckResultStatusLabel ,
992996 }
993- for _ , label := range labelsToVerify {
994- if firstCheck .Labels [label ] == "" {
995- t .Fatalf ("check %s is missing label %s" , firstCheck .Name , label )
997+ for _ , check := range checkList .Items {
998+ // Check labels with specific expected values
999+ for label , expected := range labelsWithValues {
1000+ if check .Labels [label ] != expected {
1001+ t .Fatalf ("check %s label %s: got %q, want %q" , check .Name , label , check .Labels [label ], expected )
1002+ }
1003+ }
1004+ // Check labels that must be present (non-empty)
1005+ for _ , label := range labelsPresenceOnly {
1006+ if check .Labels [label ] == "" {
1007+ t .Fatalf ("check %s is missing label %s" , check .Name , label )
1008+ }
9961009 }
9971010 }
9981011}
0 commit comments