Duration #40
@@ -276,11 +276,11 @@ pub mod metadata {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::*;
|
// use super::*;
|
||||||
|
|
||||||
|
|
||||||
mod get {
|
mod get {
|
||||||
use super::metadata::get_meta;
|
use super::super::metadata::get_meta;
|
||||||
use crate::types;
|
use crate::types;
|
||||||
use crate::test_util::util;
|
use crate::test_util::util;
|
||||||
use crate::test_util::util::{file_exists, get_full_path};
|
use crate::test_util::util::{file_exists, get_full_path};
|
||||||
@@ -536,7 +536,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod set {
|
mod set {
|
||||||
use super::metadata::{get_meta, set_meta};
|
use super::super::metadata::{get_meta, set_meta};
|
||||||
use crate::types;
|
use crate::types;
|
||||||
use crate::test_util::util;
|
use crate::test_util::util;
|
||||||
use crate::test_util::util::{file_exists, get_full_path};
|
use crate::test_util::util::{file_exists, get_full_path};
|
||||||
@@ -1074,7 +1074,7 @@ mod tests {
|
|||||||
|
|
||||||
mod pictures {
|
mod pictures {
|
||||||
|
|
||||||
use super::*;
|
use super::super::*;
|
||||||
use crate::test_util::util;
|
use crate::test_util::util;
|
||||||
use crate::test_util::util::{file_exists, get_full_path};
|
use crate::test_util::util::{file_exists, get_full_path};
|
||||||
|
|
||||||
|
@@ -24,4 +24,31 @@ pub fn get_duration(song_path: &String) -> Result<std::time::Duration,std::io::E
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
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:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user