Skip to content

Commit cf80d58

Browse files
committed
Tests: Properly catch all invalid artifacts
1 parent 049ca11 commit cf80d58

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/gardenlinux/s3/s3_artifacts.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ def upload_from_directory(
192192
"paths": [],
193193
}
194194

195+
# Catch any invalid artifacts
196+
bad_files = [
197+
f
198+
for f in artifacts_dir.iterdir()
199+
if not f.name.startswith(cname)
200+
and f.suffix not in [".release", ".requirements"]
201+
]
202+
if bad_files:
203+
raise RuntimeError(
204+
f"Artifact name '{bad_files[0].name}' does not start with cname '{cname}'"
205+
)
206+
195207
for artifact in artifacts_dir.iterdir():
196208
if not artifact.match(f"{cname}*"):
197209
continue

tests/s3/test_s3_artifacts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ def test_upload_from_directory_commit_mismatch_raises(s3_setup):
260260
bad_data = RELEASE_DATA.replace("abc123", "wrong")
261261
release_path.write_text(bad_data)
262262
artifacts = S3Artifacts(env.bucket_name)
263+
264+
# Act / Assert
263265
with pytest.raises(RuntimeError, match="Commit ID"):
264266
artifacts.upload_from_directory(env.cname, env.tmp_path)
265267

0 commit comments

Comments
 (0)