diff --git a/src/detection/song.rs b/src/detection/song.rs index 38b2097..97fd4df 100644 --- a/src/detection/song.rs +++ b/src/detection/song.rs @@ -21,3 +21,22 @@ pub fn file_type_from_filepath( pub mod constants { pub const FLAC_TYPE: &str = "flac"; } + +#[cfg(test)] +mod tests { + #[test] + fn test_song_file_type() { + let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY); + let filename = String::from("track01.flac"); + let filepath = format!("{directory}/{filename}"); + + match super::file_type_from_filepath(&filepath) { + Ok(filetype) => { + assert_eq!(filetype.file_type, crate::detection::song::constants::FLAC_TYPE, "Types do not match") + } + Err(err) => { + assert!(false, "Error: {err:?}") + } + } + } +}