"""Unit tests for the manifest compiler.""" import pytest from src.services.build.manifest_compiler import compile_dockerfile @pytest.mark.unit def test_compile_dockerfile_creates_config_dirs_for_user() -> None: """The Dockerfile must pre-create ~/.config and chown it to the container user.""" manifest = { "base_image": "ubuntu:24.04", "interface_type": "terminal", "user": {"name": "dev", "uid": 1000, "gid": 1000}, } dockerfile = compile_dockerfile(manifest) assert "groupadd -g 1000 dev" in dockerfile assert "useradd -u 1000 -g 1000 -m -s /bin/bash dev" in dockerfile assert "mkdir -p /home/dev && chown -R dev:dev /home/dev" in dockerfile assert "mkdir -p /home/dev/.config && chown -R dev:dev /home/dev/.config" in dockerfile assert "mkdir -p /home/dev/.local/share && chown -R dev:dev /home/dev/.local/share" in dockerfile assert "mkdir -p /home/dev/.cache && chown -R dev:dev /home/dev/.cache" in dockerfile @pytest.mark.unit def test_compile_dockerfile_no_user_does_not_create_home() -> None: """Without a user config, no home/user setup should be emitted.""" manifest = { "base_image": "ubuntu:24.04", "interface_type": "terminal", } dockerfile = compile_dockerfile(manifest) assert "useradd" not in dockerfile assert "/home/" not in dockerfile