Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_sync_upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ def test_sync_writes_verified_content(self) -> None:
content,
)

def test_sync_rejects_sha_mismatch_without_writing_destination(self) -> None:
expected = b"name: Expected\n"
downloaded = b"name: Unexpected\n"
source = Source(
name="workflow",
url="https://example.invalid/workflow.yml",
sha256=hashlib.sha256(expected).hexdigest(),
destination=Path("templates/workflow.yml"),
)

with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
destination = root / "templates/workflow.yml"

with patch("scripts.sync_upstream._download", return_value=downloaded):
with self.assertRaisesRegex(ValueError, "SHA-256 mismatch"):
sync([source], root)

self.assertFalse(destination.exists())

def test_check_detects_drift(self) -> None:
expected = b"name: Expected\n"
source = Source(
Expand Down
Loading