Skip to content

Commit

Permalink
update implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-carlton committed Oct 27, 2024
1 parent dd1a53f commit c67acd5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions pkg/testutils/test-framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package testutils

import (
"fmt"
"os"
"testing"
)
Expand Down Expand Up @@ -186,8 +187,13 @@ func DefaultPrepFunc(u TestUtil) {
func (u *testUtil) ResultsReporter() {
test := u.TestData()
if test.ResultsReportFunc == nil {
ReportCallSpew(u)

if test.FieldReportFunc == nil {
ReportCallSpew(u)
return
}
for index := range len(test.Results) {
test.FieldReportFunc(u, fmt.Sprintf("%d", index), test.Results[index], test.Expected[index])
}
return
}

Expand All @@ -209,8 +215,17 @@ func (u *testUtil) ResultsComparer() bool {
test := u.TestData()
passed := false

if test.ResultsCompareFunc == nil {
passed = CompareReflectDeepEqual(test.Results, test.Expected)
if test.ResultsCompareFunc == nil { //nolint: nestif
if test.FieldCompareFunc == nil {
passed = CompareReflectDeepEqual(test.Results, test.Expected)
} else {
for index := range len(test.Results) {
passed = test.FieldCompareFunc(u, fmt.Sprintf("%d", index), test.Results[index], test.Expected[index])
if !passed {
break
}
}
}
} else {
passed = test.ResultsCompareFunc(u, "", test.Results, test.Expected)
}
Expand Down

0 comments on commit c67acd5

Please sign in to comment.