test(rust): a file named like a sample folder is refused, nothing created (#384)
Review 25592, point 1: the pre-check reads exists(), not is_dir(); under is_dir() a file named "Exemple Tangerine" let "Exemple Desjardins" be created before create_dir failed with a raw "File exists". The reviewer's test pins it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ffe6288e4a
commit
f27bdc4afa
1 changed files with 17 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue