Skip to content

Commit 2ba86e4

Browse files
ankur22inancgumus
authored andcommitted
Refactor test to work with slices.IndexFunc
1 parent 9c0a28c commit 2ba86e4

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

internal/js/modules/k6/browser/tests/page_test.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -2422,13 +2422,7 @@ func TestPageOnRequest(t *testing.T) {
24222422

24232423
// Compare each request one by one for better test failure visibility
24242424
for _, req := range requests {
2425-
i := -1
2426-
for j, e := range expected {
2427-
if req.URL == e.URL {
2428-
i = j
2429-
break
2430-
}
2431-
}
2425+
i := slices.IndexFunc(expected, func(r request) bool { return req.URL == r.URL })
24322426
assert.NotEqual(t, -1, i, "failed to find expected request with URL %s", req.URL)
24332427

24342428
sortByName := func(m1, m2 map[string]string) int {

0 commit comments

Comments
 (0)