diff --git a/Cargo.toml b/Cargo.toml index 577c900..e4ada6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,3 +9,6 @@ homepape = "https://github.com/Nirusu99/ytd-rs" repository = "https://github.com/Nirusu99/ytd-rs" readme = "README.md" + +[dependencies] +regex = "1" diff --git a/src/lib.rs b/src/lib.rs index ac9f607..01413cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,27 @@ pub mod ytd; #[cfg(test)] mod tests { + use regex::Regex; + use std::env; + #[test] - fn it_works() { - assert_eq!(2 + 2, 4); + fn version() { + let ytd = crate::ytd::YoutubeDL::new( + env::current_dir() + .expect("couldn't get working directory") + .to_str() + .unwrap(), + // get youtube-dl version + vec![crate::ytd::Arg::new("--version")], + String::new(), + ) + .expect("Couldn't create youtube-dl"); + + let regex = Regex::new(r"\d{4}\.\d{2}\.\d{2}").unwrap(); + let output = ytd.download(); + + // check output + // fails if youtube-dl is not installed + assert!(regex.is_match(output.output())); } }