Dependency switch #13

Merged
phoenix merged 7 commits from switch_dependency into devel 2025-04-12 19:21:59 +00:00
Showing only changes of commit 8f2f88669d - Show all commits

View File

@@ -61,28 +61,65 @@ pub mod meta_next {
#[cfg(test)]
mod tests {
use util::{file_exists, get_full_path};
use super::*;
mod util {
pub fn get_full_path(
directory: &String,
filename: &String,
) -> Result<String, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.display().to_string()),
Err(err) => Err(err),
}
}
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.exists()),
Err(err) => Err(err),
}
}
fn path_buf(
directory: &String,
filename: &String,
) -> Result<std::path::PathBuf, std::io::Error> {
let dir_path = std::path::Path::new(&directory);
Ok(dir_path.join(filename))
}
}
#[test]
fn test_get_title() {
let filename = String::from("track01.flac");
let dir = String::from("tests/sample_tracks3");
let dir_path = std::path::Path::new(&dir);
let full_path = dir_path.join(filename);
// let dir_path = std::path::Path::new(&dir);
// let full_path = dir_path.join(filename);
println!("Path: {:?}", full_path);
// println!("Path: {:?}", full_path);
assert!(full_path.exists(), "Path does not exists {:?}", full_path);
let filepath = full_path.display().to_string();
// assert!(full_path.exists(), "Path does not exists {:?}", full_path);
match file_exists(&dir, &filename) {
Ok(_) => {
// let filepath = full_path.display().to_string();
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Title, &filepath) {
Ok(title) => {
let found = title == "Just roll it";
assert!(found, "Meta information was not found {:?}", title);
match meta_next::get_meta(meta_type::Type::Title, &filepath) {
Ok(title) => {
let found = title == "Just roll it";
assert!(found, "Meta information was not found {:?}", title);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: {:?}", err);
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
}
};
}
}