diff --git a/src/properties/mod.rs b/src/properties/mod.rs new file mode 100644 index 0000000..c8d1de8 --- /dev/null +++ b/src/properties/mod.rs @@ -0,0 +1,35 @@ +pub mod properties; + +#[cfg(test)] +mod tests { + use crate::test_util; + + #[test] + fn test_get_duration() { + let filename = test_util::util::get_filename(1); + let dir = String::from(test_util::util::TESTFILEDIRECTORY); + + match test_util::util::file_exists(&dir, &filename) { + Ok(_) => { + let filepath = test_util::util::get_full_path(&dir, &filename).unwrap(); + match super::properties::get_duration(&filepath) { + Ok(duration) => { + let song_duration: u64 = 41; + let fetched_song_duration = duration.as_secs(); + + assert_eq!( + song_duration, fetched_song_duration, + "Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})" + ); + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + } +} diff --git a/src/properties/properties.rs b/src/properties/properties.rs index 3e28031..69970e9 100644 --- a/src/properties/properties.rs +++ b/src/properties/properties.rs @@ -15,37 +15,3 @@ pub fn get_duration(song_path: &String) -> Result Err(err), } } - -#[cfg(test)] -mod tests { - use crate::test_util; - - #[test] - fn test_get_duration() { - let filename = test_util::util::get_filename(1); - let dir = String::from(test_util::util::TESTFILEDIRECTORY); - - match test_util::util::file_exists(&dir, &filename) { - Ok(_) => { - let filepath = test_util::util::get_full_path(&dir, &filename).unwrap(); - match super::get_duration(&filepath) { - Ok(duration) => { - let song_duration: u64 = 41; - let fetched_song_duration = duration.as_secs(); - - assert_eq!( - song_duration, fetched_song_duration, - "Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})" - ); - } - Err(err) => { - assert!(false, "Error: {err:?}"); - } - } - } - Err(err) => { - assert!(false, "Error: {err:?}"); - } - } - } -}