From 8d5b9d11217c403e3f2f4d5ef8ffbc078e51af21 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Fri, 31 Jan 2025 10:14:17 +0000 Subject: [PATCH] Refactor test to work with slices.IndexFunc --- internal/js/modules/k6/browser/tests/page_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/js/modules/k6/browser/tests/page_test.go b/internal/js/modules/k6/browser/tests/page_test.go index ccc6052eb4b..0905411f3ba 100644 --- a/internal/js/modules/k6/browser/tests/page_test.go +++ b/internal/js/modules/k6/browser/tests/page_test.go @@ -2404,13 +2404,7 @@ func TestPageOnRequest(t *testing.T) { // Compare each request one by one for better test failure visibility for _, req := range requests { - i := -1 - for j, e := range expected { - if req.URL == e.URL { - i = j - break - } - } + i := slices.IndexFunc(expected, func(r request) bool { return req.URL == r.URL }) assert.NotEqual(t, -1, i, "failed to find expected request with URL %s", req.URL) sortByName := func(m1, m2 map[string]string) int {