Skip to content

Commit

Permalink
Add missing await and add test for Service future creation (#42)
Browse files Browse the repository at this point in the history
* Add missing `await`

* Add test for service future creation
  • Loading branch information
SRv6d authored Feb 15, 2024
1 parent a52b503 commit 1d8af07
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/anycastd/core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ async def run_services(services: Iterable[Service]) -> None:
Args:
services: The services to run.
"""
asyncio.gather(*(service.run() for service in services))
await asyncio.gather(*(service.run() for service in services))
16 changes: 16 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest
from anycastd.core._run import run_services
from anycastd.core._service import Service


@pytest.fixture
def mock_services(mocker):
"""A set of mock services."""
return [mocker.AsyncMock(Service) for _ in range(3)]


@pytest.mark.asyncio
async def test_future_created_for_each_service(mock_services):
"""A future is created for each service."""
await run_services(mock_services)
assert all(mock_service.run.called for mock_service in mock_services)

0 comments on commit 1d8af07

Please sign in to comment.