use super::super::common::*;
#[test]
fn test_source_command_in_adhoc_mode() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&["--source-command", "ls"]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("CHANNEL Custom");
tester.send(&ctrl('c'));
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}
#[test]
fn test_source_command_override_in_channel_mode() {
let mut tester = PtyTester::new();
let mut cmd = tv_local_config_and_cable_with_args(&[
"files",
"--source-command",
"fd -t f . ./cable/",
]);
cmd.args(["--input", "files.toml"]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("./cable/unix/files.toml");
tester.send(&ctrl('c'));
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}
#[test]
fn test_source_display_with_source_command() {
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"files",
"--input",
"television",
"--source-display",
"{upper}",
]);
let mut child = tester.spawn_command_tui(cmd);
tester.assert_tui_frame_contains("TELEVISION");
tester.send(&ctrl('c'));
tester.assert_exit_ok(&mut child, DEFAULT_DELAY);
}
#[test]
fn test_source_output_with_source_command() {
use std::time::Duration;
let mut tester = PtyTester::new();
let cmd = tv_local_config_and_cable_with_args(&[
"--source-command",
"echo UNIQUE16CHARID",
"--source-output",
"echo AA{}BB",
"--take-1",
]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains_with_timeout(
"AAUNIQUE16CHARIDBB",
Duration::from_secs(2),
);
}
#[test]
fn test_source_display_without_source_command_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["--source-display", "{upper}"]);
tester.spawn_command(cmd);
tester.assert_raw_output_contains(
"source-display requires a source command",
);
}
#[test]
fn test_source_output_without_source_command_errors() {
let mut tester = PtyTester::new();
let cmd =
tv_local_config_and_cable_with_args(&["--source-output", "echo {}"]);
tester.spawn_command(cmd);
tester
.assert_raw_output_contains("source-output requires a source command");
}