from __future__ import annotations

from src.services.snapshot_paths import default_evaluations_dir, resolve_repo_root


def test_resolve_repo_root_supports_monorepo_service_layout(tmp_path):
    repo_root = tmp_path / "repo"
    evaluations_dir = repo_root / "docs" / "evaluations"
    evaluations_dir.mkdir(parents=True)
    anchor = repo_root / "apps" / "api" / "src" / "services" / "snapshot.py"
    anchor.parent.mkdir(parents=True)
    anchor.write_text("", encoding="utf-8")

    assert resolve_repo_root(anchor) == repo_root
    assert default_evaluations_dir(anchor) == evaluations_dir


def test_resolve_repo_root_supports_api_container_layout(tmp_path):
    app_root = tmp_path / "app"
    evaluations_dir = app_root / "docs" / "evaluations"
    evaluations_dir.mkdir(parents=True)
    anchor = app_root / "src" / "services" / "snapshot.py"
    anchor.parent.mkdir(parents=True)
    anchor.write_text("", encoding="utf-8")

    assert resolve_repo_root(anchor) == app_root
    assert default_evaluations_dir(anchor) == evaluations_dir
