Skip to content

Commit d11bfcb

Browse files
authored
Do not start goroutine in test (#121)
1 parent a4edb30 commit d11bfcb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/services/rpc_service_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,8 @@ func TestTrackRPCServiceHealth_UnhealthyService(t *testing.T) {
442442
mockHTTPClient.On("Post", rpcURL, "application/json", mock.Anything).
443443
Return(mockResponse, nil)
444444

445-
go rpcService.TrackRPCServiceHealth(ctx)
446-
447-
// Wait long enough for warning to trigger
448-
time.Sleep(65 * time.Second)
445+
// The ctx will timeout after 70 seconds, which is enough for the warning to trigger
446+
rpcService.TrackRPCServiceHealth(ctx)
449447

450448
entries := getLogs()
451449
testFailed := true
@@ -466,7 +464,7 @@ func TestTrackRPCService_ContextCancelled(t *testing.T) {
466464
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
467465
defer cancel()
468466

469-
go rpcService.TrackRPCServiceHealth(ctx)
467+
rpcService.TrackRPCServiceHealth(ctx)
470468

471469
// Verify channel is closed after context cancellation
472470
time.Sleep(100 * time.Millisecond)

0 commit comments

Comments
 (0)