add tests to check best format finding functions
This commit is contained in:
parent
a8a0831a52
commit
e26814e2e7
4 changed files with 29 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
/target
|
/target
|
||||||
.env
|
.env*
|
||||||
*.json
|
*.json
|
||||||
*.txt
|
*.txt
|
||||||
*.m4a
|
*.m4a
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
pub mod bot;
|
pub mod bot;
|
||||||
|
|
|
||||||
|
|
@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue