Files
Jyotisha/tests/test_railway_deployment.py
2026-08-05 11:13:34 +08:00

35 lines
1.4 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def test_railway_services_use_the_product_frontend_and_dynamic_ports() -> None:
web = (ROOT / "deploy" / "railway-web.Dockerfile").read_text(encoding="utf-8")
api = (ROOT / "deploy" / "railway-api.Dockerfile").read_text(encoding="utf-8")
assert "COPY frontend/package.json frontend/package-lock.json" in web
assert "--hostname 0.0.0.0" in web and "${PORT:-3000}" in web
assert "next-env.d.ts" not in web
assert "FROM m.daocloud.io/docker.io/library/python:3.12-slim" in api
assert "COPY SKILL.md mcp_server.py" in api
assert "--host 0.0.0.0" in api and "${PORT:-5200}" in api
assert "http.server" not in api
assert "FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/node:22-alpine" in web
def test_web_image_copies_postcss_config_before_building_frontend() -> None:
web = (ROOT / "deploy" / "railway-web.Dockerfile").read_text(encoding="utf-8")
config_copy = "COPY frontend/next.config.ts frontend/postcss.config.mjs frontend/tsconfig.json ./"
assert config_copy in web
assert web.index(config_copy) < web.index("RUN npm run build")
def test_server_compose_allows_only_the_internal_api_hostname() -> None:
compose = (ROOT / "deploy" / "docker-compose.server.yml").read_text(encoding="utf-8")
assert "JYOTISH_ALLOWED_HOSTS: localhost,127.0.0.1,::1,api" in compose