Skip to content

Commit 9d97da1

Browse files
committed
test: fail e2e tests when accuracy is 0%
Add error handling to domain classification, PII detection, and jailbreak detection tests to ensure they fail explicitly when accuracy is 0%. Previously, these tests would return nil (success) even when all test cases failed, which could mask critical issues. Now they return a descriptive error when correctTests == 0, making test failures more visible and actionable. Signed-off-by: bitliu <[email protected]>
1 parent 6a4ebf4 commit 9d97da1

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

e2e/testcases/domain_classify.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func testDomainClassify(ctx context.Context, client *kubernetes.Clientset, opts
9292
correctTests, totalTests, accuracy)
9393
}
9494

95+
// Return error if accuracy is 0%
96+
if correctTests == 0 {
97+
return fmt.Errorf("domain classification test failed: 0%% accuracy (0/%d correct)", totalTests)
98+
}
99+
95100
return nil
96101
}
97102

e2e/testcases/jailbreak_detection.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ func testJailbreakDetection(ctx context.Context, client *kubernetes.Clientset, o
103103
correctTests, totalTests, detectionRate)
104104
}
105105

106+
// Return error if detection rate is 0%
107+
if correctTests == 0 {
108+
return fmt.Errorf("jailbreak detection test failed: 0%% accuracy (0/%d correct)", totalTests)
109+
}
110+
106111
return nil
107112
}
108113

e2e/testcases/pii_detection.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ func testPIIDetection(ctx context.Context, client *kubernetes.Clientset, opts pk
103103
correctTests, totalTests, detectionRate)
104104
}
105105

106+
// Return error if detection rate is 0%
107+
if correctTests == 0 {
108+
return fmt.Errorf("PII detection test failed: 0%% accuracy (0/%d correct)", totalTests)
109+
}
110+
106111
return nil
107112
}
108113

0 commit comments

Comments
 (0)