From 397ca892f1426807cac986a521c320a8fe7c2e77 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:29:12 +0200 Subject: [PATCH] Sync tests: pass check_photo a stem-owner lookup (#1523) --- crates/engine/src/sync/tests_listing.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/sync/tests_listing.rs b/crates/engine/src/sync/tests_listing.rs index 4348ca830..099b5dd0f 100644 --- a/crates/engine/src/sync/tests_listing.rs +++ b/crates/engine/src/sync/tests_listing.rs @@ -8,6 +8,11 @@ use super::*; use crate::walk::EntryKind::{File, Folder, Other}; +/// The lookup of a photo that owns its stem sidecar, as every photo in these listings does. +fn owner(naming: SidecarNaming) -> SidecarLookup { + SidecarLookup { naming, owns_stem: true } +} + fn listing(folders: &[(&str, &[(&str, crate::walk::EntryKind)], bool)]) -> Listing { let mut l = Listing::default(); for (dir, names, complete) in folders { @@ -154,17 +159,17 @@ fn a_check_from_the_listing_is_the_check_from_the_disk() { let nothing = Listing::default(); for naming in [SidecarNaming::Stem, SidecarNaming::Full] { for p in &photos { - let from_disk = check_photo(p, naming, &c, ¬hing); - assert_eq!(check_photo(p, naming, &c, &l), from_disk, "{:?} {naming:?}", p.file_name); + let from_disk = check_photo(p, owner(naming), &c, ¬hing); + assert_eq!(check_photo(p, owner(naming), &c, &l), from_disk, "{:?} {naming:?}", p.file_name); } } let expected = [Check::Nothing, Check::News, Check::News, Check::News, Check::News, Check::News, Check::Missing, Check::Missing, Check::Missing]; - assert_eq!(photos.iter().map(|p| check_photo(p, SidecarNaming::Stem, &c, &l)).collect::>(), expected); + assert_eq!(photos.iter().map(|p| check_photo(p, owner(SidecarNaming::Stem), &c, &l)).collect::>(), expected); // what the disk was asked about the same photos, with the listing and without: fewer questions with it let asked = |l: &Listing| { for p in &photos { - check_photo(p, SidecarNaming::Stem, &c, l); + check_photo(p, owner(SidecarNaming::Stem), &c, l); } l.asked.load(std::sync::atomic::Ordering::Relaxed) }; @@ -193,7 +198,7 @@ fn a_check_from_the_listing_is_the_check_from_the_disk() { let mut c2 = Catalog::new(); for (name, expected) in [("deep.jpg", Check::News), ("gone.jpg", Check::Missing), ("gone.jpg.xmp", Check::Missing)] { let p = photo(&mut c2, &sub.join(name)); - assert_eq!(check_photo(&p, SidecarNaming::Stem, &c2, &only_plain), expected, "{name}"); + assert_eq!(check_photo(&p, owner(SidecarNaming::Stem), &c2, &only_plain), expected, "{name}"); } assert_eq!(only_plain.asked.load(std::sync::atomic::Ordering::Relaxed), 0, "every answer came from the listing"); let _ = std::fs::remove_dir_all(&dir);