Skip to content

Commit ceb50e3

Browse files
committed
tests: improve helper
1 parent 0e7f721 commit ceb50e3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/result/processors/sort_results_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ type compareTestCase struct {
7777
}
7878

7979
func testCompareValues(t *testing.T, cmp issueComparator, name string, tests []compareTestCase) {
80-
t.Parallel()
81-
8280
for i, test := range tests { //nolint:gocritic // To ignore rangeValCopy rule
8381
t.Run(fmt.Sprintf("%s(%d)", name, i), func(t *testing.T) {
82+
t.Parallel()
83+
8484
res := cmp(&test.a, &test.b)
85+
8586
assert.Equal(t, compToString(test.expected), compToString(res))
8687
})
8788
}
@@ -197,17 +198,18 @@ func Test_numericCompare(t *testing.T) {
197198
{2, 1, greater},
198199
}
199200

200-
t.Parallel()
201-
202201
for i, test := range tests {
203202
t.Run(fmt.Sprintf("%s(%d)", "Numeric Compare", i), func(t *testing.T) {
203+
t.Parallel()
204+
204205
res := numericCompare(test.a, test.b)
206+
205207
assert.Equal(t, compToString(test.expected), compToString(res))
206208
})
207209
}
208210
}
209211

210-
func TestNoSorting(t *testing.T) {
212+
func TestSortResults_Process_noSorting(t *testing.T) {
211213
tests := make([]result.Issue, len(issues))
212214
copy(tests, issues)
213215

@@ -218,7 +220,7 @@ func TestNoSorting(t *testing.T) {
218220
assert.Equal(t, tests, results)
219221
}
220222

221-
func TestSorting(t *testing.T) {
223+
func TestSortResults_Process_Sorting(t *testing.T) {
222224
tests := make([]result.Issue, len(issues))
223225
copy(tests, issues)
224226

@@ -237,7 +239,9 @@ func compToString(c int) string {
237239
return "less"
238240
case greater:
239241
return "greater"
240-
default:
242+
case equal:
241243
return "equal"
244+
default:
245+
return "error"
242246
}
243247
}

0 commit comments

Comments
 (0)