From 41f11ed275949b131568abe6354bbb435b08a828 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 18 Apr 2025 20:50:27 -0400 Subject: [PATCH] Added test --- src/meta.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/meta.rs b/src/meta.rs index a2ea158..b7c9855 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -1030,5 +1030,42 @@ mod tests { } }; } + + #[test] + fn test_remove_picture() { + let filename = util::get_filename(1); + let dir = String::from(util::TESTFILEDIRECTORY); + + let temp_file = tempfile::tempdir().expect("Could not create test directory"); + let test_dir = String::from(temp_file.path().to_str().unwrap()); + let test_filename = String::from("track09.flac"); + let new_filepath = get_full_path(&test_dir, &test_filename).unwrap(); + + // let new_coverart = String::from("Sample Tracks 3 - Other one.png"); + // let new_cover_art_path = get_full_path(&dir, &new_coverart).unwrap(); + + match file_exists(&dir, &filename) { + Ok(_) => { + let filepath = get_full_path(&dir, &filename).unwrap(); + + match util::copy_file(&filepath, &new_filepath) { + Ok(_o) => match coverart::remove_coverart(&new_filepath) { + Ok(bytes) => { + assert_eq!(false, bytes.is_empty(), "This should not be empty"); + } + Err(err) => { + assert!(false, "Error: {:?}", err); + } + }, + Err(err) => { + assert!(false, "Error: {:?}", err); + } + } + } + Err(err) => { + assert!(false, "Error: File does not exist {:?}", err.to_string()); + } + }; + } } }