test_gfg_d2_bridge_roundtrip.py
file-level
1
files
1
commits
0
hotspots
0
🧊 dead
0
💥 blast risk
| 1 | """Data-integrity: muse_commit_id preserved including sha256: prefix (§D2F.9).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | from pathlib import Path |
| 6 | |
| 7 | from adapters.base import read_bridge_git_sha, read_bridge_muse_commit_id |
| 8 | from tests.support import adapter_for, make_runner |
| 9 | |
| 10 | |
| 11 | def test_muse_commit_id_roundtrip_preserves_prefix( |
| 12 | muse_git_mirror_config, repo_root: Path |
| 13 | ) -> None: |
| 14 | tip = "sha256:67001f71f4481906b1bad7a9f46ccf61f9113c44a6cf64473416c4c77a8b6116" |
| 15 | git_sha = "1e734a922a8de5dcac248007b8dfb706c4a0f84e" |
| 16 | muse = repo_root / ".muse" |
| 17 | muse.mkdir(parents=True) |
| 18 | original = ( |
| 19 | f'[last_export]\n' |
| 20 | f'muse_commit_id = "{tip}"\n' |
| 21 | f'git_sha = "{git_sha}"\n' |
| 22 | ) |
| 23 | path = muse / "git-bridge.toml" |
| 24 | path.write_text(original, encoding="utf-8") |
| 25 | |
| 26 | assert read_bridge_muse_commit_id(repo_root, "last_export") == tip |
| 27 | assert read_bridge_git_sha(repo_root, "last_export") == git_sha |
| 28 | adapter = adapter_for(muse_git_mirror_config, repo_root, make_runner({})) |
| 29 | anchor = adapter.read_canonical_anchor() |
| 30 | assert anchor.anchor_sha == tip |
| 31 | # Reading must not mutate bridge bytes |
| 32 | assert path.read_text(encoding="utf-8") == original |