use tempfile::TempDir;
use super::super::common::*;
#[test]
fn test_watch_reloads_source_command() {
let mut tester = PtyTester::new();
let tmp_dir = TempDir::new().unwrap();
std::fs::write(tmp_dir.path().join("UNIQUE16CHARIDfile.txt"), "").unwrap();
let cmd = tv_local_config_and_cable_with_args(&[
"--watch",
"0.5",
"--source-command",
"ls",
"--input",
"UNIQUE16CHARID",
tmp_dir.path().to_str().unwrap(),
]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("UNIQUE16CHARIDfile.txt");
std::fs::write(tmp_dir.path().join("UNIQUE16CHARIDcontrol.txt"), "")
.unwrap();
std::thread::sleep(std::time::Duration::from_millis(2000));
tester.assert_tui_frame_contains("UNIQUE16CHARIDcontrol.txt");
tester.send(&ctrl('c'));
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}
#[test]
fn test_tick_rate_valid_value_starts_application() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["files", "--tick-rate", "50"]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("CHANNEL files");
tester.send(&ctrl('c'));
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}
#[test]
fn test_tick_rate_invalid_value_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["files", "--tick-rate", "-5"]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains("unexpected argument");
}