Files
pkgmgr/tests/integration/test_repository_paths_exist.py
Kevin Veen-Birkenbach db9aaf920e
Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / codesniffer-shellcheck (push) Has been cancelled
Mark stable commit / codesniffer-ruff (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
refactor(release,version): centralize repository path resolution and validate template layout
- Introduce RepoPaths resolver as single source of truth for repository file locations
- Update release workflow to use resolved packaging and changelog paths
- Update version readers to rely on the shared path resolver
- Add integration test asserting pkgmgr repository satisfies canonical template layout

https://chatgpt.com/share/693eaa75-98f0-800f-adca-439555f84154
2025-12-14 13:15:41 +01:00

65 lines
2.0 KiB
Python

# tests/integration/test_repository_paths_exist.py
from __future__ import annotations
import os
from pathlib import Path
import pytest
from pkgmgr.core.repository.paths import resolve_repo_paths
def _find_repo_root() -> Path:
"""
Locate the pkgmgr repository root from the test location.
This assumes the standard layout:
repo_root/
src/pkgmgr/...
tests/integration/...
"""
here = Path(__file__).resolve()
for parent in here.parents:
if (parent / "pyproject.toml").is_file() and (parent / "src" / "pkgmgr").is_dir():
return parent
raise RuntimeError("Could not determine repository root for pkgmgr integration test")
def test_pkgmgr_repository_paths_exist() -> None:
"""
Integration test: verify that the pkgmgr repository provides all
canonical files defined by RepoPaths.
pkgmgr acts as the TEMPLATE repository for all other packages.
Therefore, every path resolved here is expected to exist.
"""
repo_root = _find_repo_root()
paths = resolve_repo_paths(str(repo_root))
missing: list[str] = []
def _require(path: str | None, description: str) -> None:
if not path:
missing.append(f"{description}: <not resolved>")
return
if not os.path.isfile(path):
missing.append(f"{description}: {path} (missing)")
# Core metadata (must always exist)
_require(paths.pyproject_toml, "pyproject.toml")
_require(paths.flake_nix, "flake.nix")
# Human-facing changelog (pkgmgr must provide one)
_require(paths.changelog_md, "CHANGELOG.md")
# Packaging files (pkgmgr is the reference implementation)
_require(paths.arch_pkgbuild, "Arch PKGBUILD")
_require(paths.debian_changelog, "Debian changelog")
_require(paths.rpm_spec, "RPM spec file")
if missing:
pytest.fail(
"pkgmgr repository does not satisfy the canonical repository layout:\n"
+ "\n".join(f" - {item}" for item in missing)
)