fn test_make_mount_unit()

in metalos/metalctl/src/generator.rs [977:1051]


    fn test_make_mount_unit() -> Result<()> {
        assert_eq!(
            make_mount_unit(
                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,
                },
                Path::new("/test_rootdisk"),
            )
            .context("failed to write moot disk")?,
            MountUnit {
                unit_section: UnitSection::default(),
                mount_section: MountSection {
                    what: "LABEL=unittest".into(),
                    where_: "/test_rootdisk".into(),
                    options: Some("f1,f2,f3,rw".to_string()),
                    type_: Some("testfs".to_string()),
                }
            }
        );
        assert_eq!(
            make_mount_unit(
                Root {
                    root: Some("LABEL=unittest".to_string()),
                    fstype: None,
                    flags: None,
                    ro: true,
                    rw: false,
                },
                Path::new("/test_rootdisk"),
            )
            .context("failed to write moot disk")?,
            MountUnit {
                unit_section: UnitSection::default(),
                mount_section: MountSection {
                    what: "LABEL=unittest".into(),
                    where_: "/test_rootdisk".into(),
                    options: Some("ro".to_string()),
                    type_: None,
                }
            }
        );

        assert!(
            make_mount_unit(
                Root {
                    root: None,
                    fstype: None,
                    flags: None,
                    ro: true,
                    rw: false,
                },
                Path::new("/test_rootdisk"),
            )
            .is_err()
        );

        assert!(
            make_mount_unit(
                Root {
                    root: Some("/dev/vda".into()),
                    fstype: None,
                    flags: None,
                    ro: true,
                    rw: false,
                },
                Path::new("/test_rootdisk"),
            )
            .is_err()
        );
        Ok(())
    }