use assert_cmd::Command;
use predicates::prelude::*;
fn bin() -> Command {
Command::cargo_bin("youtube-legend-cli").expect("binary")
}
#[test]
fn provider_auto_parses_and_lists_all_in_help() {
bin()
.arg("--provider")
.arg("auto")
.arg("--timeout")
.arg("1")
.arg("https://youtu.be/dQw4w9WgXcQ")
.timeout(std::time::Duration::from_secs(10))
.assert()
.failure();
let help = bin()
.arg("--help")
.timeout(std::time::Duration::from_secs(5))
.assert()
.success()
.get_output()
.stdout
.clone();
let help_str = String::from_utf8_lossy(&help);
assert!(help_str.contains("auto"), "--help missing `auto` token");
assert!(
help_str.contains("youtube-direct"),
"--help missing `youtube-direct` token"
);
assert!(
help_str.contains("provider-a"),
"--help missing `provider-a` token"
);
assert!(
help_str.contains("provider-b"),
"--help missing `provider-b` token"
);
assert!(
help_str.contains("provider-headless"),
"--help missing `provider-headless` token"
);
}
#[test]
fn provider_youtube_direct_parses() {
bin()
.arg("--provider")
.arg("youtube-direct")
.arg("--timeout")
.arg("1")
.arg("https://youtu.be/INVALID_ID_FOR_TEST")
.timeout(std::time::Duration::from_secs(10))
.assert()
.failure();
}
#[test]
fn provider_a_rejects_asr() {
bin()
.arg("--provider")
.arg("provider-a")
.arg("--asr")
.timeout(std::time::Duration::from_secs(5))
.assert()
.failure()
.code(64)
.stderr(predicate::str::contains("--asr"));
}
#[test]
fn provider_b_rejects_asr() {
bin()
.arg("--provider")
.arg("provider-b")
.arg("--asr")
.timeout(std::time::Duration::from_secs(5))
.assert()
.failure()
.code(64)
.stderr(predicate::str::contains("provider-b"));
}
#[test]
fn no_fallback_requires_auto_provider() {
bin()
.arg("--provider")
.arg("provider-a")
.arg("--no-fallback")
.timeout(std::time::Duration::from_secs(5))
.assert()
.failure()
.code(64)
.stderr(predicate::str::contains("--no-fallback"));
}