81b9a66ef5
- Delete 4 obsolete unit tests tied to removed git mount/clone models - Update imports and assertions across unit/integration/service tests - Fix Settings defaults (postgres host, JWT props, cookie_samesite) - Add skip guards for PostgreSQL-dependent integration tests - Fix GitService env assertions and HealthMonitor state-change tests - Repair docker/container inspect assertions in test_docker_service - Fix ToolTypeCreate default_port validator ordering bug - Fix check_port_exposed substring false-positive for port 0 - Update test_tool_types_api_extended to use interface_type field Quality gates: pytest 311 passed, 34 skipped; npm typecheck/lint/test 87 passed
77 lines
3.0 KiB
Python
77 lines
3.0 KiB
Python
"""Unit tests for ~ / $HOME expansion in container paths."""
|
|
|
|
import pytest
|
|
|
|
from src.services.config.config_profile_resolver import expand_container_path
|
|
from src.services.build.manifest_compiler import get_manifest_home_dir
|
|
|
|
|
|
class TestExpandContainerPath:
|
|
"""Tests for expand_container_path helper."""
|
|
|
|
def test_tilde_slash_expands(self) -> None:
|
|
"""~/foo should expand to home_dir/foo."""
|
|
assert (
|
|
expand_container_path("~/workspace", "/home/user") == "/home/user/workspace"
|
|
)
|
|
|
|
def test_tilde_alone_expands(self) -> None:
|
|
"""~ should expand to home_dir."""
|
|
assert expand_container_path("~", "/home/user") == "/home/user"
|
|
|
|
def test_dollar_home_slash_expands(self) -> None:
|
|
"""$HOME/foo should expand to home_dir/foo."""
|
|
assert (
|
|
expand_container_path("$HOME/workspace", "/home/user")
|
|
== "/home/user/workspace"
|
|
)
|
|
|
|
def test_dollar_home_alone_expands(self) -> None:
|
|
"""$HOME should expand to home_dir."""
|
|
assert expand_container_path("$HOME", "/home/user") == "/home/user"
|
|
|
|
def test_absolute_path_unchanged(self) -> None:
|
|
"""Absolute paths should not be modified."""
|
|
assert expand_container_path("/app/workspace", "/home/user") == "/app/workspace"
|
|
|
|
def test_relative_path_unchanged(self) -> None:
|
|
"""Relative paths should not be modified."""
|
|
assert expand_container_path("workspace", "/home/user") == "workspace"
|
|
|
|
def test_tilde_in_middle_unchanged(self) -> None:
|
|
"""~ in the middle of a path should not expand."""
|
|
assert expand_container_path("/app/~user", "/home/user") == "/app/~user"
|
|
|
|
def test_dollar_home_in_middle_unchanged(self) -> None:
|
|
"""$HOME in the middle of a path should not expand."""
|
|
assert expand_container_path("/app/$HOMEuser", "/home/user") == "/app/$HOMEuser"
|
|
|
|
def test_root_home(self) -> None:
|
|
"""Expansion works with /root as home."""
|
|
assert expand_container_path("~/config", "/root") == "/root/config"
|
|
|
|
|
|
class TestGetManifestHomeDir:
|
|
"""Tests for get_manifest_home_dir helper."""
|
|
|
|
def test_with_user_block(self) -> None:
|
|
"""Manifest with user block returns /home/{name}."""
|
|
manifest = {"user": {"name": "developer", "uid": 1000, "gid": 1000}}
|
|
assert get_manifest_home_dir(manifest) == "/home/developer"
|
|
|
|
def test_without_user_block(self) -> None:
|
|
"""Manifest without user block returns /root."""
|
|
manifest = {"base_image": "ubuntu:24.04"}
|
|
assert get_manifest_home_dir(manifest) == "/root"
|
|
|
|
def test_with_empty_user_name(self) -> None:
|
|
"""Manifest with empty user name returns /root."""
|
|
manifest = {"user": {"name": "", "uid": 1000, "gid": 1000}}
|
|
assert get_manifest_home_dir(manifest) == "/root"
|
|
|
|
def test_with_none_user_name(self) -> None:
|
|
"""Manifest with None user name returns /root."""
|
|
manifest = {"user": {"name": None, "uid": 1000, "gid": 1000}}
|
|
assert get_manifest_home_dir(manifest) == "/root"
|
|
|