repo-manager/tests/test_scaffold.py
tegwick 7ea7690dfc fix registrar writebacks and own the State Hub access map
Ignore generated WORK-RECORDS.md/.custodian-brief.md in the registrar git
precondition, commit identifier writebacks even when registration is
incomplete, and name the remaining records in the error. Add
config/state-hub-access.yaml as the single source for the AGENTS.md port
map, rendered by rmgr scaffold and refreshed with --refresh-hub-access.

Assistant: grok
Assistant-Session: 01a04996-76e8-7f53-b971-1885cfbed436
2026-08-28 20:48:21 +02:00

79 lines
2.8 KiB
Python

from pathlib import Path
from repo_manager.cli import main
from repo_manager.commands.scaffold import scaffold_repository
from repo_manager.standards import check_repository
def test_prj_scaffold_requires_prefix(tmp_path: Path):
dest = tmp_path / "prj-example"
result = scaffold_repository(dest, flavor="project", commit=False)
assert result.status == "rejected"
assert "wp-prefix" in (result.error or {}).get("message", "").lower() or "PRJ" in str(
result.error
)
def test_prj_scaffold_refuses_flavor_prefix(tmp_path: Path):
dest = tmp_path / "prj-example"
result = scaffold_repository(dest, flavor="project", wp_prefix="PRJ-WP", commit=False)
assert result.status == "rejected"
def test_prj_scaffold_writes_goal_not_intent(tmp_path: Path):
dest = tmp_path / "prj-example-cutover"
result = scaffold_repository(
dest, flavor="project", wp_prefix="EXCO-WP", commit=False
)
assert result.status == "applied"
assert (dest / "GOAL.md").is_file()
assert not (dest / "INTENT.md").exists()
goal = (dest / "GOAL.md").read_text()
for heading in ("Outcome", "Invariants", "Success gates", "Project retirement"):
assert heading in goal
assert not list((dest / "workplans").glob("*-0001-*.md"))
report = check_repository(dest)
assert report.ok, report.to_dict()
def test_durable_scaffold_writes_intent(tmp_path: Path):
dest = tmp_path / "some-tool"
result = scaffold_repository(dest, flavor="tooling", commit=False)
assert result.status == "applied"
assert (dest / "INTENT.md").is_file()
assert not (dest / "GOAL.md").exists()
assert (dest / "workplans" / "SOMETOOL-WP-0001-foundation.md").is_file()
report = check_repository(dest)
assert report.ok, report.to_dict()
def test_scaffold_rerun_is_an_applied_noop(tmp_path: Path):
dest = tmp_path / "stable-tool"
first = scaffold_repository(dest, flavor="tooling", commit=False)
before = {path.relative_to(dest): path.read_bytes() for path in dest.rglob("*") if path.is_file()}
second = scaffold_repository(dest, flavor="tooling", commit=False)
after = {path.relative_to(dest): path.read_bytes() for path in dest.rglob("*") if path.is_file()}
assert first.status == second.status == "applied"
assert second.evidence["noop"] is True
assert second.evidence["written"] == []
assert after == before
def test_cli_scaffold(tmp_path: Path):
dest = tmp_path / "cli-tool"
assert (
main(
[
"scaffold",
"--path",
str(dest),
"--flavor",
"tooling",
"--no-commit",
]
)
== 0
)
assert (dest / "INTENT.md").is_file()
agents = (dest / "AGENTS.md").read_text(encoding="utf-8")
assert "10.43.68.154:8000" in agents