diff --git a/src-tauri/src/commands/fs_commands.rs b/src-tauri/src/commands/fs_commands.rs index 0d90f42..d3ddd43 100644 --- a/src-tauri/src/commands/fs_commands.rs +++ b/src-tauri/src/commands/fs_commands.rs @@ -456,6 +456,23 @@ mod sample_folder_tests { assert_eq!(entries, 1, "nothing but the existing folder"); } + /// A FILE named like a sample folder blocks it as well (#384 review): the + /// check reads `exists()`, not `is_dir()`, so nothing is half-created and + /// the refusal keeps its code instead of a raw "File exists" from + /// `create_dir`. + #[test] + fn refuses_a_file_named_like_a_sample_folder_and_writes_nothing() { + let dir = sandbox("file-tangerine"); + fs::write(dir.join(SAMPLE_TANGERINE_FOLDER), "").unwrap(); + let result = create_sample_import_folders(as_arg(&dir), "2026-09-25".to_string()); + let desjardins_created = dir.join(SAMPLE_DESJARDINS_FOLDER).exists(); + let entries = fs::read_dir(&dir).unwrap().count(); + cleanup(&dir); + assert_eq!(result.unwrap_err(), "sample_folder_exists:Exemple Tangerine"); + assert!(!desjardins_created, "Exemple Desjardins must not be created"); + assert_eq!(entries, 1, "nothing but the existing file"); + } + #[test] fn writes_both_folders_for_the_two_previous_months() { let dir = sandbox("success");