Files
Octop/tests/unit/test_docker_compose_database_env.py
T
jubaoliang ecad9ec3da feat: chat stream resume, shared terminal dock, and thread title repair (#157)
Keep dashboard chat turns attachable after reconnect, reuse one terminal
session store across Workbench and the chat dock, and migrate legacy
hard-cut thread titles to clipped titles with ellipsis.
2026-08-04 15:40:58 +08:00

30 lines
1.1 KiB
Python

"""Compose must forward OCTOP_DATABASE_* into the container (issue #152)."""
from __future__ import annotations
from pathlib import Path
from octop.config import _DATABASE_ENV_KEYS
def _compose_environment_entries(compose_text: str) -> str:
"""Return list-item lines under the octop service ``environment:`` key."""
marker = "\n environment:\n"
env_idx = compose_text.index(marker) + len(marker)
lines: list[str] = []
for line in compose_text[env_idx:].splitlines():
if line.startswith(" - "):
lines.append(line)
continue
break
return "\n".join(lines)
def test_docker_compose_forwards_database_env_keys() -> None:
"""docker/.env alone does not inject vars — they must be listed under environment."""
repo = Path(__file__).resolve().parents[2]
text = (repo / "docker" / "docker-compose.yml").read_text(encoding="utf-8")
env_text = _compose_environment_entries(text)
missing = [k for k in _DATABASE_ENV_KEYS if f"{k}=" not in env_text]
assert not missing, f"docker-compose.yml environment missing: {missing}"