add tests to check best format finding functions

This commit is contained in:
mykola2312 2024-02-21 15:05:18 +02:00
parent a8a0831a52
commit e26814e2e7
4 changed files with 29 additions and 3 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
/target /target
.env .env*
*.json *.json
*.txt *.txt
*.m4a *.m4a

View file

@ -170,3 +170,29 @@ impl YtDlp {
Ok(YtDlpInfo::parse(&output.stdout)?) Ok(YtDlpInfo::parse(&output.stdout)?)
} }
} }
#[cfg(test)]
mod tests {
use super::YtDlp;
use std::env;
#[tokio::test]
async fn best_av_format() {
dotenv::from_filename(".env.test").unwrap();
let info = YtDlp::load_info(env::var("TEST_URL").unwrap().as_str())
.await
.unwrap();
let video = info.best_av_format().unwrap();
assert_eq!(video.format_id, "22");
}
#[tokio::test]
async fn best_audio_format() {
dotenv::from_filename(".env.test").unwrap();
let info = YtDlp::load_info(env::var("TEST_URL").unwrap().as_str())
.await
.unwrap();
let video = info.best_audio_format().unwrap();
assert_eq!(video.format_id, "140");
}
}

View file

@ -1,5 +1,5 @@
use std::env;
use dotenv::dotenv; use dotenv::dotenv;
use std::env;
mod bot; mod bot;
use bot::bot::bot_main; use bot::bot::bot_main;