Skip to content

Commit 1d21bc0

Browse files
committed
Addressed Lance's comments
1 parent 85c81f7 commit 1d21bc0

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

tests/e2e/framework/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,7 @@ func (f *Framework) AssertHasCheck(suiteName, scanName string, check compv1alpha
21752175

21762176
return nil
21772177
}
2178+
21782179
func (f *Framework) AssertHasRemediations(suiteName, scanName, roleLabel string, remNameList []string) error {
21792180
var scanSuiteMapNames = make(map[string]bool)
21802181
var scanSuiteRemediations []compv1alpha1.ComplianceRemediation

tests/e2e/parallel/main_test.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)