Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Use pg.get_container_host_ip and pg.get_connection_url (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x authored Dec 7, 2022
1 parent 06c9fea commit 65aa17f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
⌛️ [running Python SDK tests](${{ env.RUN_URL }})...
- run: poetry install
- run: poetry run pytest -s
env:
TC_HOST: 172.17.0.1
- name: Comment on failure
if: ${{ github.event.inputs.prNumber && failure() }}
uses: marocchino/sticky-pull-request-comment@v2
Expand Down
22 changes: 14 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,28 @@ class SeamBackend:
@pytest.fixture(scope="function")
def seam_backend():
with PostgresContainer("postgres:13", dbname="postgres") as pg:
db_host = (
"host.docker.internal"
if sys.platform == "darwin"
else "172.17.0.1"
)
db_url = f"postgresql://test:test@{db_host}:{pg.get_exposed_port(pg.port_to_expose)}/postgres"
db_host = pg.get_container_host_ip()
db_url = pg.get_connection_url()

# UPSTREAM: https://github.com/testcontainers/testcontainers-python/issues/159
docker_info = pg.get_docker_client().client.info()
if docker_info["OperatingSystem"] == "Docker Desktop":
container_host = "host.docker.internal"
db_url = db_url.replace(db_host, container_host)
db_host = container_host

with DockerContainer(
os.environ.get(
"SEAM_CONNECT_IMAGE", "ghcr.io/seamapi/seam-connect"
)
).with_env("DATABASE_URL", db_url,).with_env(
).with_env(
"DATABASE_URL", db_url
).with_env(
"POSTGRES_DATABASE", "postgres"
).with_env(
"NODE_ENV", "test"
).with_env(
"POSTGRES_HOST", db_host
"POSTGRES_HOST", db_host,
).with_env(
"SERVER_BASE_URL", "http://localhost:3020"
).with_env(
Expand Down

0 comments on commit 65aa17f

Please sign in to comment.