Skip to content

Commit

Permalink
[FIX] Test postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
josep-tecnativa committed Feb 5, 2025
1 parent 01512c3 commit 5e432a2
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions tests/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,6 @@ def _get_db_service_name(dc: DockerClient) -> str:
return "db"


def _get_db_service_name(dc: DockerClient) -> str:
"""
Use python-on-whales to retrieve the final Compose configuration
and return the DB service name that ends with '-db'. Fallback to
any service containing 'db' or 'postgres'. Finally, fallback to 'db'.
"""
config_data = dc.compose.config() # Returns a dict with { "services": {...}, ... }
services_dict = config_data["services"]
# First pass: Look for a service name that exactly ends with '-db'
for svc_name in services_dict:
if svc_name.lower().endswith("-db"):
return svc_name

# Second pass: Fallback to any name containing 'db' or 'postgres'
for svc_name in services_dict:
if "postgres" in svc_name.lower() or "db" in svc_name.lower():
return svc_name

# Final fallback
return "db"


@pytest.mark.parametrize("dbver", ("oldest", "latest"))
def test_postgresql_client_versions(
cloned_template: Path,
Expand Down

0 comments on commit 5e432a2

Please sign in to comment.