Skip to content

Commit

Permalink
Do not start goroutine in test (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 authored Jan 29, 2025
1 parent a4edb30 commit d11bfcb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/services/rpc_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,8 @@ func TestTrackRPCServiceHealth_UnhealthyService(t *testing.T) {
mockHTTPClient.On("Post", rpcURL, "application/json", mock.Anything).
Return(mockResponse, nil)

go rpcService.TrackRPCServiceHealth(ctx)

// Wait long enough for warning to trigger
time.Sleep(65 * time.Second)
// The ctx will timeout after 70 seconds, which is enough for the warning to trigger
rpcService.TrackRPCServiceHealth(ctx)

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

go rpcService.TrackRPCServiceHealth(ctx)
rpcService.TrackRPCServiceHealth(ctx)

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

0 comments on commit d11bfcb

Please sign in to comment.