summaryrefslogtreecommitdiff
path: root/tests/build.rs
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 06:02:57 +0000
committerHermes Agent <hermes@localhost>2026-08-12 06:02:57 +0000
commitc7dc1a0173a14e9cb52adcb09ae566cf7eeb314a (patch)
tree62661aaa98e09a9abadb676dec1863469464ce5a /tests/build.rs
parent35af190cac33650b90e8056b890b8c2c03dca7e7 (diff)
Protect companion manifests from overwrite
Diffstat (limited to 'tests/build.rs')
-rw-r--r--tests/build.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs
index 6613cc7..c6ed70d 100644
--- a/tests/build.rs
+++ b/tests/build.rs
@@ -113,6 +113,29 @@ fn rejects_an_existing_artifact_before_creating_the_workspace_or_installing() {
}
#[test]
+fn rejects_an_existing_companion_manifest_before_creating_the_workspace_or_installing() {
+ let fixture = tempdir().expect("fixture directory");
+ let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml"))
+ .expect("load controller spec");
+ let plan = BuildPlan::compile(spec).expect("compile build plan");
+ let installer = FixtureInstaller::default();
+ let mut executor = BuildExecutor::new(&installer, FixtureInitramfsBuilder);
+ let workspace = fixture.path().join("work");
+ let artifact = fixture.path().join("controller.tar");
+ let companion = ArtifactManifest::path_beside(&artifact).expect("companion manifest path");
+ fs::write(&companion, "do not replace").expect("write pre-existing companion manifest");
+
+ let error = executor
+ .execute(&plan, &workspace, "profiles/apt.conf", &artifact)
+ .expect_err("pre-existing companion manifest must be rejected");
+
+ assert!(error.to_string().contains("output manifest already exists"));
+ assert_eq!(fs::read_to_string(&companion).expect("read companion manifest"), "do not replace");
+ assert!(!workspace.exists());
+ assert!(installer.requests.borrow().is_empty());
+}
+
+#[test]
fn rejects_a_missing_apt_configuration_before_creating_the_workspace() {
let fixture = tempdir().expect("fixture directory");
let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml"))