File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments