from pathlib import Path

from aitop.version import __version__

PROJECT_ROOT = Path(__file__).resolve().parents[1]


def _read_project_file(relative_path: str) -> str:
    return (PROJECT_ROOT / relative_path).read_text(encoding="utf-8")


def test_release_metadata_tracks_current_version() -> None:
    readme = _read_project_file("README.md")
    assert f"Current version: {__version__}" in readme
    assert f"advanced beta (v{__version__})" in readme

    changelog = _read_project_file("CHANGELOG.md")
    assert f"## [{__version__}] -" in changelog
    assert f"mark `{__version__}` as current" in changelog

    threading = _read_project_file("THREADING.md")
    assert f"### v{__version__} (Current)" in threading

    pyproject = _read_project_file("pyproject.toml")
    assert f"current release: {__version__}" in pyproject
