From 1593a1b712d7fc8e444ad6064b84312e3a20ee49 Mon Sep 17 00:00:00 2001 From: Marc Plano-Lesay Date: Sat, 7 Dec 2024 13:01:20 +1100 Subject: [PATCH] Add some tests for auto create albums --- src/commands/auto_create_albums.rs | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/commands/auto_create_albums.rs b/src/commands/auto_create_albums.rs index f9fc061..6679567 100644 --- a/src/commands/auto_create_albums.rs +++ b/src/commands/auto_create_albums.rs @@ -116,3 +116,45 @@ fn extract_album_names(folder_path: PathBuf, separator: String) -> Vec { components } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn extract_album_names_root() { + let folder_path = PathBuf::new(); + let separator = String::from("//"); + + let names = extract_album_names(folder_path, separator); + + assert_eq!(names, vec![] as Vec); + } + + #[test] + fn extract_album_names_first_level() { + let folder_path = PathBuf::from("My holiday photos"); + let separator = String::from("//"); + + let names = extract_album_names(folder_path, separator); + + assert_eq!(names, vec!["My holiday photos"]); + } + + #[test] + fn extract_album_names_third_level() { + let folder_path = PathBuf::from("My holiday photos/Europe/Toulouse"); + let separator = String::from("//"); + + let names = extract_album_names(folder_path, separator); + + assert_eq!( + names, + vec![ + "My holiday photos", + "My holiday photos//Europe", + "My holiday photos//Europe//Toulouse", + ] + ); + } +}