@@ -202,6 +202,56 @@ 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 (
230+ RuntimeError ,
231+ match = "Release file data and given cname conflict detected: Version None" ,
232+ ):
233+ artifacts .upload_from_directory (env .cname , env .tmp_path )
234+
235+
236+ def test_upload_from_directory_invalid_artifact_name (s3_setup ):
237+ """
238+ Raise RuntimeError if artifact file does not start with cname.
239+ """
240+ # Arrange
241+ env = s3_setup
242+ (env .tmp_path / f"{ env .cname } .release" ).write_text (RELEASE_DATA )
243+
244+ # Create "bad" artifact that does not start with cname
245+ bad_file = env .tmp_path / "no_match"
246+ bad_file .write_bytes (b"oops" )
247+
248+ artifacts = S3Artifacts (env .bucket_name )
249+
250+ # Act / Assert
251+ with pytest .raises (RuntimeError , match = "does not start with cname" ):
252+ artifacts .upload_from_directory (env .cname , env .tmp_path )
253+
254+
205255def test_upload_from_directory_commit_mismatch_raises (s3_setup ):
206256 """Raise RuntimeError when commit ID is not matching with cname."""
207257 # Arrange
0 commit comments