From 87404737532ec9a742e57037bfd6f892906b4c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Thu, 15 Aug 2024 17:48:54 +0200 Subject: [PATCH] Add test loop --- client/internal/routemanager/client_test.go | 40 +++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/client/internal/routemanager/client_test.go b/client/internal/routemanager/client_test.go index 8bdb44361..1827519dc 100644 --- a/client/internal/routemanager/client_test.go +++ b/client/internal/routemanager/client_test.go @@ -172,26 +172,28 @@ func TestGetBestrouteFromStatuses(t *testing.T) { }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - currentRoute := &route.Route{ - ID: "routeDoesntExistAnymore", - } - if tc.currentRoute != "" { - currentRoute = tc.existingRoutes[tc.currentRoute] - } + for i := 0; i < 10; i++ { + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + currentRoute := &route.Route{ + ID: "routeDoesntExistAnymore", + } + if tc.currentRoute != "" { + currentRoute = tc.existingRoutes[tc.currentRoute] + } - // create new clientNetwork - client := &clientNetwork{ - handler: static.NewRoute(&route.Route{Network: netip.MustParsePrefix("192.168.0.0/24")}, nil, nil), - routes: tc.existingRoutes, - currentChosen: currentRoute, - } + // create new clientNetwork + client := &clientNetwork{ + handler: static.NewRoute(&route.Route{Network: netip.MustParsePrefix("192.168.0.0/24")}, nil, nil), + routes: tc.existingRoutes, + currentChosen: currentRoute, + } - chosenRoute := client.getBestRouteFromStatuses(tc.statuses) - if chosenRoute != tc.expectedRouteID { - t.Errorf("expected routeID %s, got %s", tc.expectedRouteID, chosenRoute) - } - }) + chosenRoute := client.getBestRouteFromStatuses(tc.statuses) + if chosenRoute != tc.expectedRouteID { + t.Errorf("expected routeID %s, got %s", tc.expectedRouteID, chosenRoute) + } + }) + } } }