summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compare.rs51
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");