test_version_lock.py file-level

at main · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:8 docs: queue board-identity follow-ups so they survive the session Capt… · aaronrene · Sep 5, 2026
1 """Unit tests for version.lock reader/writer."""
2
3 from __future__ import annotations
4
5 from pathlib import Path
6
7 import pytest
8
9 from cli.version_lock import (
10 LockError,
11 build_version_lock,
12 read_version_lock,
13 write_version_lock,
14 )
15
16
17 def test_round_trip(tmp_path: Path) -> None:
18 lock = build_version_lock(
19 kit_version="0.1.0",
20 config_version=1,
21 footprint=[("docs/A.md", "templates/A.template.md", b"hello\n")],
22 )
23 path = tmp_path / "version.lock"
24 write_version_lock(path, lock)
25 loaded = read_version_lock(path)
26 assert loaded.kit_version == "0.1.0"
27 assert len(loaded.footprint) == 1
28 assert loaded.footprint[0].path == "docs/A.md"
29
30
31 def test_unknown_lock_version_raises(tmp_path: Path) -> None:
32 path = tmp_path / "version.lock"
33 path.write_text(
34 "lock_version: 99\nkit_version: 0.1.0\nconfig_version: 1\n"
35 'installed_at: "2026-01-01T00:00:00Z"\n'
36 'synced_at: "2026-01-01T00:00:00Z"\n'
37 'footprint_digest: "sha256:00"\nfootprint: []\n',
38 encoding="utf-8",
39 )
40 with pytest.raises(LockError, match="unsupported lock_version"):
41 read_version_lock(path)
42
43
44 def test_missing_keys_raises(tmp_path: Path) -> None:
45 path = tmp_path / "version.lock"
46 path.write_text("lock_version: 1\n", encoding="utf-8")
47 with pytest.raises(LockError, match="missing required key"):
48 read_version_lock(path)