ddd92e3dd4
- Add ToolType.home_directory column with default /home/user
- Add Alembic migration to add column, set existing rows, and rewrite
/workspace to /home/user/{{WORKSPACE_NAME}} in legacy templates
- Add merge migration fc8f1a20cbf6 to resolve Alembic multiple heads
- Update manifest compiler to honor manifest.home_directory for HOME,
WORKDIR, /workspace symlink, and default repo mount target
- Update legacy dockerfile/compose instance generation to use
tool_type.home_directory
- Thread resolved home_dir through config profile and git mount expansion
- Generate entrypoint permission fixer to chown home/mounts at startup
- Update base.dockerfile with sudo/passwordless sudo for permission fixer
- Add unit tests for manifest compiler, instance service, and migrations
- Add placeholder integration test for container lifecycle
- Update openspec/tasks/home-path-expansion.md task checkboxes
- Update project maps for modified files
Quality gates: py_compile, ruff, mypy, pytest tests/unit (205 passed),
pytest tests/integration (110 passed, 35 skipped). Alembic round-trip
and container lifecycle integration tests require Docker/PostgreSQL.
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""Unit tests for the tool instance service."""
|
|
|
|
import pytest
|
|
|
|
from src.services.tool.instance_service import modify_compose_file
|
|
|
|
|
|
@pytest.mark.unit
|
|
class TestModifyComposeFile:
|
|
"""Tests for modify_compose_file home-directory expansion."""
|
|
|
|
def test_extra_volumes_expand_home_dir(self, tmp_path):
|
|
compose_path = tmp_path / "docker-compose.yml"
|
|
compose_path.write_text(
|
|
'services:\n app:\n image: test:latest\n volumes: []\n'
|
|
)
|
|
|
|
modify_compose_file(
|
|
str(compose_path),
|
|
extra_volumes=[
|
|
{"source": "/host/config", "target": "~/.config", "type": "bind"},
|
|
{"source": "/host/code", "target": "$HOME/code", "type": "bind"},
|
|
],
|
|
home_dir="/home/user",
|
|
)
|
|
|
|
content = compose_path.read_text()
|
|
assert "/host/config:/home/user/.config" in content
|
|
assert "/host/code:/home/user/code" in content
|
|
|
|
def test_working_directory_expands_home_dir(self, tmp_path):
|
|
compose_path = tmp_path / "docker-compose.yml"
|
|
compose_path.write_text(
|
|
'services:\n app:\n image: test:latest\n'
|
|
)
|
|
|
|
modify_compose_file(
|
|
str(compose_path),
|
|
working_directory="~/workspace",
|
|
home_dir="/home/user",
|
|
)
|
|
|
|
content = compose_path.read_text()
|
|
assert "working_dir: /home/user/workspace" in content
|