Added test

This commit is contained in:
2025-04-12 12:20:57 -04:00
parent 302b1d2b71
commit 50ada1d484

View File

@@ -19,22 +19,16 @@ mod meta {
pub fn get_meta(t: meta_type::Type, filepath: &String) -> Result<String, taglib::FileError> {
match t {
meta_type::Type::Title => {
match get_file(filepath) {
Ok(file) => {
match get_tag(&file) {
Ok(tag) => {
match tag.title() {
Some(title) => Ok(title),
None => Err(taglib::FileError::NoAvailableTag)
}
}
Err(err) => Err(err)
}
}
Err(err) => Err(err)
}
}
meta_type::Type::Title => match get_file(filepath) {
Ok(file) => match get_tag(&file) {
Ok(tag) => match tag.title() {
Some(title) => Ok(title),
None => Err(taglib::FileError::NoAvailableTag),
},
Err(err) => Err(err),
},
Err(err) => Err(err),
},
_ => Err(taglib::FileError::InvalidFile),
}
}
@@ -57,4 +51,16 @@ mod tests {
let result = add(2, 2);
assert_eq!(result, 4);
}
#[test]
fn test_get_title() {
let filename = String::from("track01.flac");
let dir = String::from("tests");
let dir_path = std::path::Path::new(&dir);
let full_path = dir_path.join(filename);
println!("Path: {:?}", full_path);
assert!(full_path.exists(), "Path does not exists {:?}", full_path);
}
}