test(integration): add unittest-based repository layout contract test
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
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
- Add integration test using unittest to verify canonical repository paths - Assert pkgmgr repository satisfies template layout (packaging, changelog, metadata) - Use real filesystem without mocks or pytest dependencies https://chatgpt.com/share/693eaa75-98f0-800f-adca-439555f84154
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
# tests/integration/test_repository_paths_exist.py
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from pkgmgr.core.repository.paths import resolve_repo_paths
|
||||
|
||||
|
||||
@@ -13,7 +11,7 @@ def _find_repo_root() -> Path:
|
||||
"""
|
||||
Locate the pkgmgr repository root from the test location.
|
||||
|
||||
This assumes the standard layout:
|
||||
Assumes:
|
||||
repo_root/
|
||||
src/pkgmgr/...
|
||||
tests/integration/...
|
||||
@@ -25,40 +23,43 @@ def _find_repo_root() -> Path:
|
||||
raise RuntimeError("Could not determine repository root for pkgmgr integration test")
|
||||
|
||||
|
||||
def test_pkgmgr_repository_paths_exist() -> None:
|
||||
class TestRepositoryPathsExist(unittest.TestCase):
|
||||
"""
|
||||
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.
|
||||
Integration test: pkgmgr is the TEMPLATE repository.
|
||||
All canonical paths resolved for pkgmgr must exist.
|
||||
"""
|
||||
repo_root = _find_repo_root()
|
||||
paths = resolve_repo_paths(str(repo_root))
|
||||
|
||||
missing: list[str] = []
|
||||
def test_pkgmgr_repository_paths_exist(self) -> None:
|
||||
repo_root = _find_repo_root()
|
||||
paths = resolve_repo_paths(str(repo_root))
|
||||
|
||||
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)")
|
||||
missing: list[str] = []
|
||||
|
||||
# Core metadata (must always exist)
|
||||
_require(paths.pyproject_toml, "pyproject.toml")
|
||||
_require(paths.flake_nix, "flake.nix")
|
||||
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)")
|
||||
|
||||
# Human-facing changelog (pkgmgr must provide one)
|
||||
_require(paths.changelog_md, "CHANGELOG.md")
|
||||
# Core metadata
|
||||
require(paths.pyproject_toml, "pyproject.toml")
|
||||
require(paths.flake_nix, "flake.nix")
|
||||
|
||||
# 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")
|
||||
# Human changelog
|
||||
require(paths.changelog_md, "CHANGELOG.md")
|
||||
|
||||
if missing:
|
||||
pytest.fail(
|
||||
"pkgmgr repository does not satisfy the canonical repository layout:\n"
|
||||
+ "\n".join(f" - {item}" for item in missing)
|
||||
)
|
||||
# Packaging files (pkgmgr defines the template)
|
||||
require(paths.arch_pkgbuild, "Arch PKGBUILD")
|
||||
require(paths.debian_changelog, "Debian changelog")
|
||||
require(paths.rpm_spec, "RPM spec file")
|
||||
|
||||
if missing:
|
||||
self.fail(
|
||||
"pkgmgr repository does not satisfy the canonical repository layout:\n"
|
||||
+ "\n".join(f" - {item}" for item in missing)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user