Skip to content

Commit

Permalink
Clean up after timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Nov 27, 2024
1 parent ccd6558 commit 59528b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/http/check_until_broker_ready_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestCheckUntilBrokerReadyHappyPath(t *testing.T) {
}))
defer server.Close()

ctx, cancel := context.WithTimeout(context.Background(), tt.timeout)
defer cancel()

done := make(chan error)
go func() {
done <- CheckUntilBrokerReady(server.URL)
Expand All @@ -54,7 +57,7 @@ func TestCheckUntilBrokerReadyHappyPath(t *testing.T) {
t.Errorf("expected at most %d requests, got %d", tt.maxReqs, requestCount)
}

case <-time.After(tt.timeout):
case <-ctx.Done():
t.Errorf("test timed out after %v", tt.timeout)
}
})
Expand Down

0 comments on commit 59528b6

Please sign in to comment.