from pathlib import Path


def test_shared_host_postgres_assets_are_present_and_isolated():
    root = Path(__file__).resolve().parents[1]
    compose_yaml = (root / "deployment" / "docker-compose.postgres.server.yml").read_text(encoding="utf-8")
    env_template = (root / ".env.postgres.server.template").read_text(encoding="utf-8")
    gitignore = (root / ".gitignore").read_text(encoding="utf-8")

    assert "name: call-center-postgres" in compose_yaml
    assert "image: postgres:16-alpine" in compose_yaml
    assert "../.env.postgres.server" in compose_yaml
    assert "127.0.0.1:5434:5432" in compose_yaml
    assert "../.data_pg:/var/lib/postgresql/data" in compose_yaml
    assert 'pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"' in compose_yaml

    assert "POSTGRES_DB=mvpcc" in env_template
    assert "POSTGRES_USER=mvpcc_app" in env_template
    assert "POSTGRES_PASSWORD=" in env_template

    assert ".data_pg/" in gitignore
    assert ".env.postgres.server" in gitignore
