Skip to content

Commit f8d2774

Browse files
authored
Merge pull request #26 from LibreCodeCoop/test/upstream-sha-mismatch
test: cover upstream SHA mismatch failure
2 parents 1d431a6 + 0fec1d2 commit f8d2774

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/test_sync_upstream.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ def test_sync_writes_verified_content(self) -> None:
129129
content,
130130
)
131131

132+
def test_sync_rejects_sha_mismatch_without_writing_destination(self) -> None:
133+
expected = b"name: Expected\n"
134+
downloaded = b"name: Unexpected\n"
135+
source = Source(
136+
name="workflow",
137+
url="https://example.invalid/workflow.yml",
138+
sha256=hashlib.sha256(expected).hexdigest(),
139+
destination=Path("templates/workflow.yml"),
140+
)
141+
142+
with tempfile.TemporaryDirectory() as directory:
143+
root = Path(directory)
144+
destination = root / "templates/workflow.yml"
145+
146+
with patch("scripts.sync_upstream._download", return_value=downloaded):
147+
with self.assertRaisesRegex(ValueError, "SHA-256 mismatch"):
148+
sync([source], root)
149+
150+
self.assertFalse(destination.exists())
151+
132152
def test_check_detects_drift(self) -> None:
133153
expected = b"name: Expected\n"
134154
source = Source(

0 commit comments

Comments
 (0)