summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 06:31:13 +0000
committerHermes Agent <hermes@localhost>2026-08-12 06:31:13 +0000
commit200df1f46cc5a5a5659c90ab37c2ba624cb17b5a (patch)
treed0f0c2580ad9a6b73f3c3adc5b43908093b5f631 /tests
parent80686835f4d6ef1a42a97ffcfbc48746861a129c (diff)
Prefer companion manifests during artifact comparison
Diffstat (limited to 'tests')
-rw-r--r--tests/cli.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index b800e68..648962b 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -1,7 +1,11 @@
+use std::fs;
use std::path::PathBuf;
-use alt_controller_image::cli::{Cli, Command};
+use alt_controller_image::archive::NativeTarWriter;
+use alt_controller_image::cli::{run, Cli, Command};
+use alt_controller_image::manifest::{ArtifactManifest, PackageRecord};
use clap::Parser;
+use tempfile::tempdir;
#[test]
fn parses_plan_with_an_explicit_spec_path() {
@@ -69,3 +73,31 @@ fn parses_compare_with_explicit_artifact_paths() {
if left == PathBuf::from("legacy.tar") && right == PathBuf::from("native.tar")
));
}
+
+#[test]
+fn compare_uses_companion_manifests_for_tar_artifacts() {
+ let fixture = tempdir().expect("temporary directory");
+ let rootfs = fixture.path().join("rootfs");
+ fs::create_dir_all(&rootfs).expect("create rootfs");
+ let left = fixture.path().join("left.tar");
+ let right = fixture.path().join("right.tar");
+ NativeTarWriter::new().write(&rootfs, &left).expect("write left archive");
+ NativeTarWriter::new().write(&rootfs, &right).expect("write right archive");
+ ArtifactManifest::new(
+ vec![PackageRecord::new("controller", "1.0")], vec![], None, vec![], vec![],
+ )
+ .expect("left manifest")
+ .write_beside(&left)
+ .expect("write left companion manifest");
+ ArtifactManifest::new(
+ vec![PackageRecord::new("controller", "2.0")], vec![], None, vec![], vec![],
+ )
+ .expect("right manifest")
+ .write_beside(&right)
+ .expect("write right companion manifest");
+
+ let error = run(Cli { command: Command::Compare { left, right } })
+ .expect_err("companion package difference must be reported");
+
+ assert!(error.to_string().contains("artifacts differ semantically"));
+}