fn test_metalos_reimage_boot_info()

in metalos/metalctl/src/generator.rs [745:823]


    fn test_metalos_reimage_boot_info() -> Result<()> {
        let boot_info_result = metalos_reimage_boot_info(
            Root {
                root: Some("LABEL=unittest".to_string()),
                fstype: Some("testfs".to_string()),
                flags: Some(vec!["f1".to_string(), "f2".to_string(), "f3".to_string()]),
                ro: false,
                rw: true,
            },
            "test_config_uri".to_string(),
            "test_reimage_package:123".to_string(),
            Some("11:22:33:44:55:66".to_string()),
        )
        .context("failed to get boot info")?;

        let boot_id = get_boot_id().context("failed to get boot id")?;

        assert_eq!(
            boot_info_result.env,
            MetalosReimageEnvironment {
                metalos_common: MetalosEnvironment {
                    host_config_uri: "test_config_uri".to_string(),
                    rootdisk_dir: "/run/fs/control".into(),
                    metalos_boots_dir: "/run/fs/control/run/boot".into(),
                    metalos_current_boot_dir: format!("/run/fs/control/run/boot/0:{}", boot_id)
                        .into(),
                    metalos_images_dir: "/run/fs/control/image".into(),
                },
                disk_image_package: "test_reimage_package:123".to_string(),
            }
        );

        assert_eq!(
            boot_info_result.extra_deps,
            btreemap! {
                "metalos_boot".to_string() => ExtraDependency {
                    source: "metalos-switch-root.service".into(),
                    requires: "metalos-snapshot-root.service".into(),
                },
                "metalos_reimage_boot".to_string() => ExtraDependency {
                    source: "run-fs-control.mount".into(),
                    requires: "metalos-image-root-disk.service".into(),
                },
                "apply_host_config".to_string() => ExtraDependency {
                    source: "metalos-switch-root.service".into(),
                    requires: "metalos-apply-host-config.service".into(),
                },
            }
        );

        assert_eq!(
            boot_info_result.mount_unit,
            MountUnit {
                unit_section: UnitSection::default(),
                mount_section: MountSection {
                    what: "LABEL=unittest".into(),
                    where_: "/run/fs/control".into(),
                    options: Some("f1,f2,f3,rw".to_string()),
                    type_: Some("testfs".to_string()),
                }
            }
        );

        assert_eq!(
            boot_info_result.network_unit_dropin,
            Some(Dropin {
                target: ETH_NETWORK_UNIT_FILENAME.into(),
                unit: NetworkUnit {
                    match_section: NetworkUnitMatchSection {
                        name: "eth*".to_string(),
                        mac_address: "11:22:33:44:55:66".to_string()
                    },
                },
                dropin_filename: Some("match.conf".to_string()),
            })
        );

        Ok(())
    }