Skip to content

Commit

Permalink
tests: improve helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Nov 23, 2024
1 parent 0e7f721 commit ede25e5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/result/processors/sort_results_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ type compareTestCase struct {
}

func testCompareValues(t *testing.T, cmp issueComparator, name string, tests []compareTestCase) {
t.Parallel()
t.Helper()

for i, test := range tests { //nolint:gocritic // To ignore rangeValCopy rule
t.Run(fmt.Sprintf("%s(%d)", name, i), func(t *testing.T) {
t.Parallel()

res := cmp(&test.a, &test.b)

assert.Equal(t, compToString(test.expected), compToString(res))
})
}
Expand Down Expand Up @@ -197,11 +200,12 @@ func Test_numericCompare(t *testing.T) {
{2, 1, greater},
}

t.Parallel()

for i, test := range tests {
t.Run(fmt.Sprintf("%s(%d)", "Numeric Compare", i), func(t *testing.T) {
t.Parallel()

res := numericCompare(test.a, test.b)

assert.Equal(t, compToString(test.expected), compToString(res))
})
}
Expand Down Expand Up @@ -237,7 +241,9 @@ func compToString(c int) string {
return "less"
case greater:
return "greater"
default:
case equal:
return "equal"
default:
return "error"
}
}

0 comments on commit ede25e5

Please sign in to comment.