@@ -202,6 +202,53 @@ def test_upload_from_directory_version_mismatch_raises(s3_setup):
202202 artifacts .upload_from_directory (env .cname , env .tmp_path )
203203
204204
205+ def test_upload_from_directory_none_version_raises (monkeypatch , s3_setup ):
206+ """
207+ Raise RuntimeError if CName.version is None.
208+ """
209+ # Arrange
210+ env = s3_setup
211+ (env .tmp_path / f"{ env .cname } .release" ).write_text (RELEASE_DATA )
212+
213+ import gardenlinux .s3 .s3_artifacts as s3art
214+
215+ class DummyCName :
216+ arch = "amd64"
217+ version = None
218+ commit_id = "abc123"
219+ platform = "aws"
220+
221+ def __init__ (self , cname ):
222+ pass
223+
224+ monkeypatch .setattr (s3art , "CName" , DummyCName )
225+
226+ artifacts = s3art .S3Artifacts (env .bucket_name )
227+
228+ # Act / Assert
229+ with pytest .raises (RuntimeError , match = "CName version could not be determined" ):
230+ artifacts .upload_from_directory (env .cname , env .tmp_path )
231+
232+
233+ def test_upload_from_directory_invalid_artifact_name (s3_setup ):
234+ """
235+ Raise RuntimeError if artifact file does not start with cname.
236+ """
237+ # Arrange
238+ env = s3_setup
239+ (env .tmp_path / f"{ env .cname } .release" ).write_text (RELEASE_DATA )
240+
241+ # Create "bad" artifact that does not start with cname
242+ bad_file = env .tmp_path / "no_match"
243+ bad_file .write_bytes (b"oops" )
244+
245+ artifacts = S3Artifacts (env .bucket_name )
246+
247+ # Act / Assert
248+ with pytest .raises (RuntimeError , match = "does not start with cname" ):
249+ artifacts .upload_from_directory (env .cname , env .tmp_path )
250+
251+
205252def test_upload_from_directory_commit_mismatch_raises (s3_setup ):
206253 """Raise RuntimeError when commit ID is not matching with cname."""
207254 # Arrange
0 commit comments