Skip to content

Commit f24bf03

Browse files
committed
Use t.Error instead of t.Fatal for assertion checking
The tests will fail if there are any discrepancies between the expected cluster state and the observed state. Using t.Fataf() or t.Fatal marks the test as failed, which is what we want, but it also stop execution of the test. Since we have some helper methods that process the mismatched results to generate assertion files and reports, we don't want to completely stop execution so that we can still produce those files. This commit updates those specific parts of the tests to use Error instead of Fatal so we perserve the behavior to mark the test as failed, but continue processing in the test to cleanup and generate reports.
1 parent def3a79 commit f24bf03

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

e2e_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestPlatformCompliance(t *testing.T) {
169169
if err = helpers.GenerateMismatchReport(tc, c, mismatchedAssertions, platformBindingName); err != nil {
170170
t.Fatalf("Failed to generate test report: %s", err)
171171
}
172-
t.Fatal("Actual cluster compliance state didn't match expected state")
172+
t.Error("Actual cluster compliance state didn't match expected state")
173173
}
174174

175175
err = helpers.GenerateAssertionFileFromResults(tc, c, assertionFileName, initialResults, finalResults)
@@ -282,7 +282,7 @@ func TestNodeCompliance(t *testing.T) {
282282
if err = helpers.GenerateMismatchReport(tc, c, mismatchedAssertions, nodeBindingName); err != nil {
283283
t.Fatalf("Failed to generate test report: %s", err)
284284
}
285-
t.Fatal("Actual cluster compliance state didn't match expected state")
285+
t.Error("Actual cluster compliance state didn't match expected state")
286286
}
287287

288288
err = helpers.GenerateAssertionFileFromResults(tc, c, assertionFileName, initialResults, finalResults)
@@ -352,7 +352,7 @@ func TestProfile(t *testing.T) {
352352
if err = helpers.GenerateMismatchReport(tc, c, mismatchedAssertions, bindingName); err != nil {
353353
t.Fatalf("Failed to generate test report: %s", err)
354354
}
355-
t.Fatal("Actual cluster compliance state didn't match expected state")
355+
t.Error("Actual cluster compliance state didn't match expected state")
356356
}
357357

358358
err = helpers.GenerateAssertionFileFromResults(tc, c, assertionFileName, initialResults, nil)
@@ -477,7 +477,7 @@ func TestProfileRemediations(t *testing.T) {
477477
if err = helpers.GenerateMismatchReport(tc, c, mismatchedAssertions, bindingName); err != nil {
478478
t.Fatalf("Failed to generate test report: %s", err)
479479
}
480-
t.Fatal("Actual cluster compliance state didn't match expected state")
480+
t.Error("Actual cluster compliance state didn't match expected state")
481481
}
482482

483483
err = helpers.GenerateAssertionFileFromResults(tc, c, assertionFileName, initialResults, finalResults)

0 commit comments

Comments
 (0)