補強 P4 report 正式機 no-git 回讀
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-02 15:06:54 +08:00
parent edc3f1fdc3
commit ffbcdc0793
2 changed files with 130 additions and 1 deletions

View File

@@ -169,3 +169,54 @@ def test_text_output_exposes_source_deployment_and_runtime_layers(tmp_path):
assert "production_health: healthy postgresql V10.725" in text
assert "deployment_files_hashed: 2" in text
assert "truth_layers_separated: true" in text
def test_report_can_use_source_overrides_for_no_git_deployment_tree(tmp_path):
source_root = _write_source_root(tmp_path)
payload = report.build_report(
root=source_root,
tracked_files=("config.py", "proof.txt"),
source_override={
"branch": "main",
"head": LOCAL_HEAD,
"origin_main": LOCAL_HEAD,
"origin_dev": LOCAL_HEAD,
"gitea_main": LOCAL_HEAD,
"gitea_dev": LOCAL_HEAD,
"head_config_version": "V10.725",
"tracked_files_committed": True,
},
runner=lambda args, cwd: (_ for _ in ()).throw(AssertionError("git should not run")),
health_fetcher=_health(),
)
assert payload["result"] == "PASS"
assert payload["source_control"]["source_mode"] == "override_for_no_git_deployment_tree"
assert payload["summary"]["source_control_ok"] is True
assert payload["summary"]["tracked_files_committed"] is True
def test_source_override_still_requires_committed_file_confirmation(tmp_path):
source_root = _write_source_root(tmp_path)
payload = report.build_report(
root=source_root,
tracked_files=("config.py", "proof.txt"),
source_override={
"branch": "main",
"head": LOCAL_HEAD,
"origin_main": LOCAL_HEAD,
"origin_dev": LOCAL_HEAD,
"gitea_main": LOCAL_HEAD,
"gitea_dev": LOCAL_HEAD,
"head_config_version": "V10.725",
"tracked_files_committed": False,
},
runner=lambda args, cwd: (_ for _ in ()).throw(AssertionError("git should not run")),
health_fetcher=_health(),
)
assert payload["result"] == "BLOCKED"
assert payload["summary"]["tracked_files_committed"] is False
assert any("uncommitted source-control changes" in error for error in payload["errors"])