From 271ccc76ad22436b7e0d5291168a5d18c57bb77b Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 01:59:47 +0000 Subject: Compare semantic facts directly from tar artifacts --- tests/compare.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tests') diff --git a/tests/compare.rs b/tests/compare.rs index b11d288..59b62cb 100644 --- a/tests/compare.rs +++ b/tests/compare.rs @@ -120,3 +120,39 @@ fn collects_semantic_facts_from_native_rootfs_and_tar_artifact() { .iter() .any(|record| record == &ArchiveMemberRecord::new("etc/controller-link", "symlink"))); } + +#[test] +fn collects_comparable_semantic_facts_directly_from_a_tar_artifact() { + let fixture = tempdir().expect("temporary directory"); + let rootfs = fixture.path().join("rootfs"); + fs::create_dir_all(rootfs.join("etc/systemd/system/multi-user.target.wants")) + .expect("create service state directory"); + fs::create_dir_all(rootfs.join("boot")).expect("create boot directory"); + fs::write(rootfs.join("etc/controller.conf"), "controller\n").expect("write file"); + fs::write(rootfs.join("boot/initrd-rt.img"), "initrd\n").expect("write initrd"); + symlink( + "/usr/lib/systemd/system/controller.service", + rootfs.join("etc/systemd/system/multi-user.target.wants/controller.service"), + ) + .expect("enable service"); + let artifact = fixture.path().join("controller.tar"); + NativeTarWriter::new() + .write(&rootfs, &artifact) + .expect("write native tar"); + + let manifest = ArtifactManifest::collect_archive(&artifact).expect("collect archive facts"); + + assert_eq!(manifest.packages, Vec::::new()); + assert!(manifest.files.iter().any(|record| record == &FileRecord::file( + "etc/controller.conf", + "2d5c759b2b539229e09d362e8dbe0ae410ff8c9ece6038624458724520683f5b", + ))); + assert_eq!( + manifest.initrd, + Some(InitrdRecord::new( + "boot/initrd-rt.img", + "8f7ed204b9dfaa20aa484445f54233c4b407cb80ec0f8c07f1f0a59675fb44cf", + )) + ); + assert_eq!(manifest.services, vec![ServiceRecord::new("controller.service", true)]); +} -- cgit v1.2.3