Skip to content

Commit

Permalink
fix: zero test result
Browse files Browse the repository at this point in the history
Allow IsEmpty returns true even if there is no test cases included in a test execution(failed, passed, skipped are all 0), provided that PassedTestsRate is not empty string.
  • Loading branch information
jzli committed Dec 13, 2022
1 parent 9975550 commit 23c0fea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/codequality/v1alpha1/unit_tests_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (t *TestResult) IsEmpty() bool {
if t == nil {
return true
}
return t.Failed+t.Passed+t.Skipped == 0
return t.Failed+t.Passed+t.Skipped == 0 && t.PassedTestsRate == ""
}

// GetObjectWithValues inits an object based on a json.path values map
Expand Down
6 changes: 6 additions & 0 deletions apis/codequality/v1alpha1/unit_tests_funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ func TestUnitTestsResultIsEmpty(t *testing.T) {
g.Expect(object.IsEmpty()).To(gomega.BeFalse())
})

t.Run("has results with zero values", func(t *testing.T) {
g := gomega.NewGomegaWithT(t)
object := UnitTestsResult{TestResult: &TestResult{PassedTestsRate: "0.00"}}
g.Expect(object.IsEmpty()).To(gomega.BeFalse())
})

t.Run("nil results with coverage", func(t *testing.T) {
g := gomega.NewGomegaWithT(t)
object := UnitTestsResult{Coverage: &TestCoverage{Lines: "1"}}
Expand Down

0 comments on commit 23c0fea

Please sign in to comment.