From c7dc1a0173a14e9cb52adcb09ae566cf7eeb314a Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 06:02:57 +0000 Subject: Protect companion manifests from overwrite --- tests/compare.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/compare.rs') diff --git a/tests/compare.rs b/tests/compare.rs index f7b3a04..4f48721 100644 --- a/tests/compare.rs +++ b/tests/compare.rs @@ -158,6 +158,21 @@ fn writes_distinct_manifests_for_artifacts_in_the_same_directory() { assert_eq!(ArtifactManifest::load(&native_path).expect("load native manifest"), native_manifest); } +#[test] +fn refuses_to_overwrite_an_existing_companion_manifest() { + let fixture = tempdir().expect("temporary directory"); + let artifact = fixture.path().join("controller.tar"); + let manifest_path = ArtifactManifest::path_beside(&artifact).expect("manifest path"); + fs::write(&manifest_path, "preserve this manifest").expect("write existing manifest"); + + let error = baseline() + .write_beside(&artifact) + .expect_err("existing companion manifests must not be overwritten"); + + assert!(error.to_string().contains("create artifact manifest")); + assert_eq!(fs::read_to_string(&manifest_path).expect("read existing manifest"), "preserve this manifest"); +} + #[test] fn rejects_duplicate_semantic_keys() { let error = ArtifactManifest::new( -- cgit v1.2.3