use std::time::Duration;
use clap::Parser;
use pretty_assertions::assert_eq;
use super::rerun_args;
use crate::cli::{Cli, Command, DaemonCommand};
#[test]
fn rerun_arguments_run_the_same_daemon_with_the_handoff() {
let handoff = "7:9".to_owned();
let unload_idle_after = Duration::from_millis(1500);
let args =
std::iter::once("rho".into()).chain(rerun_args(unload_idle_after, Some(handoff.clone())));
let parsed = Cli::try_parse_from(args).unwrap().command;
let Some(Command::Daemon {
command:
Some(DaemonCommand::Run {
unload_idle_after: parsed_idle,
exec_handoff: Some(parsed_handoff),
}),
}) = parsed
else {
panic!("not `rho daemon run` with a handoff: {parsed:?}");
};
assert_eq!(
(parsed_idle, parsed_handoff),
(Some(unload_idle_after), handoff)
);
}