Skip to content

Commit 26094bf

Browse files
committed
install: add unit tests
1 parent f43c6ad commit 26094bf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/cmdline/install.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,4 +584,30 @@ dest-device: u
584584
.expand_config_files()
585585
.unwrap_err();
586586
}
587+
588+
/// Test that firstboot-args is manually added to args list when defined
589+
#[test]
590+
fn test_firstboot_args_manually_added() {
591+
let mut f = NamedTempFile::new().unwrap();
592+
f.as_file_mut().write_all(b"dest-device: /dev/sda").unwrap();
593+
594+
let config = InstallConfig::from_args(&[
595+
"--config-file",
596+
f.path().to_str().unwrap(),
597+
"--firstboot-args",
598+
"ip=dhcp",
599+
])
600+
.unwrap();
601+
602+
// Verify firstboot-args is defined
603+
assert!(config.firstboot_args.is_some());
604+
assert_eq!(config.firstboot_args.as_ref().unwrap(), "ip=dhcp");
605+
606+
// Test expand_config_files to verify manual addition
607+
let expanded = config.expand_config_files().unwrap();
608+
609+
// Should still have firstboot-args
610+
assert!(expanded.firstboot_args.is_some());
611+
assert_eq!(expanded.firstboot_args.unwrap(), "ip=dhcp");
612+
}
587613
}

0 commit comments

Comments
 (0)