diff options
| author | Hermes Agent <hermes@localhost> | 2026-08-12 03:53:08 +0000 |
|---|---|---|
| committer | Hermes Agent <hermes@localhost> | 2026-08-12 03:53:08 +0000 |
| commit | 815ec6e06e05f03022c2076f6e8573f1d2c454c9 (patch) | |
| tree | 1cfd033f74ec4c4c617e7e410e0d2ea16e595e13 /tests/compare.rs | |
| parent | 0fad03030080f99d7d1e0a360146f66245165eae (diff) | |
Avoid duplicate initrd manifest facts
Diffstat (limited to 'tests/compare.rs')
| -rw-r--r-- | tests/compare.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/compare.rs b/tests/compare.rs index 8bc1a07..2e06a39 100644 --- a/tests/compare.rs +++ b/tests/compare.rs @@ -79,6 +79,57 @@ fn distinguishes_added_and_removed_initrd_records() { } #[test] +fn archive_collection_records_an_initrd_once_as_a_dedicated_boot_fact() { + let fixture = tempdir().expect("temporary directory"); + let rootfs = fixture.path().join("rootfs"); + fs::create_dir_all(rootfs.join("boot")).expect("create boot directory"); + fs::write(rootfs.join("boot/initrd-6.12-rt1.img"), "initrd\n").expect("write initrd"); + let artifact = fixture.path().join("controller.tar"); + NativeTarWriter::new() + .write(&rootfs, &artifact) + .expect("write native archive"); + + let manifest = ArtifactManifest::collect_archive(&artifact).expect("collect archive facts"); + + assert_eq!( + manifest.initrd, + Some(InitrdRecord::new( + "boot/initrd-6.12-rt1.img", + "8f7ed204b9dfaa20aa484445f54233c4b407cb80ec0f8c07f1f0a59675fb44cf", + )) + ); + assert!(manifest + .files + .iter() + .all(|record| record.path != "boot/initrd-6.12-rt1.img")); +} + +#[test] +fn rootfs_collection_records_a_supplied_initrd_once_as_a_dedicated_boot_fact() { + let fixture = tempdir().expect("temporary directory"); + let rootfs = fixture.path().join("rootfs"); + fs::create_dir_all(rootfs.join("boot")).expect("create boot directory"); + fs::write(rootfs.join("boot/initrd-6.12-rt1.img"), "initrd\n").expect("write initrd"); + let artifact = fixture.path().join("controller.tar"); + NativeTarWriter::new() + .write(&rootfs, &artifact) + .expect("write native archive"); + let initrd = InitrdRecord::new( + "boot/initrd-6.12-rt1.img", + "8f7ed204b9dfaa20aa484445f54233c4b407cb80ec0f8c07f1f0a59675fb44cf", + ); + + let manifest = ArtifactManifest::collect(&rootfs, vec![], Some(initrd.clone()), &artifact) + .expect("collect rootfs facts"); + + assert_eq!(manifest.initrd, Some(initrd)); + assert!(manifest + .files + .iter() + .all(|record| record.path != "boot/initrd-6.12-rt1.img")); +} + +#[test] fn reads_and_writes_a_toml_manifest_beside_an_artifact() { let fixture = tempdir().expect("temporary directory"); let artifact = fixture.path().join("controller.tar"); |