From 8a5a7c19d7ee7bf09179ad7c01e544057bf7b091 Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Tue, 29 Sep 2026 21:31:53 -0400 Subject: [PATCH] test(filename_audit): seed library 2 before its image_exif row (#151) run_audit_skips_disabled_and_offline_libraries inserted an image_exif row for library 2, which migrations never create, tripping the image_exif.library_id foreign key. Insert the libraries row first so the suite is green on master again. Also fix the cmp_owned clippy warning in the filename_audit bin. Closes #151 Co-Authored-By: Claude Opus 5.5 --- src/bin/filename_audit.rs | 2 +- src/filename_audit.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bin/filename_audit.rs b/src/bin/filename_audit.rs index 34ed53a..f72cfce 100644 --- a/src/bin/filename_audit.rs +++ b/src/bin/filename_audit.rs @@ -56,7 +56,7 @@ fn main() -> anyhow::Result<()> { && let base = PathBuf::from(base) && !libraries .iter() - .any(|l| PathBuf::from(&l.root_path) == base) + .any(|l| std::path::Path::new(&l.root_path) == base) { eprintln!( "note: BASE_PATH ({}) does not match any library root; auditing the library table", diff --git a/src/filename_audit.rs b/src/filename_audit.rs index 8532de6..c51547e 100644 --- a/src/filename_audit.rs +++ b/src/filename_audit.rs @@ -484,6 +484,20 @@ mod tests { // missing_root is never created -> probe fails. let mut conn = migrated_conn(); + // Migrations only seed library 1; image_exif.library_id is a + // foreign key, so library 2 must exist before its row does. + { + use crate::database::schema::libraries; + diesel::insert_into(libraries::table) + .values(( + libraries::id.eq(2), + libraries::name.eq("offline"), + libraries::root_path.eq(missing_root.to_string_lossy().to_string()), + libraries::created_at.eq(1_700_000_000), + )) + .execute(&mut conn) + .expect("seed library"); + } // Give the offline library a row so had_data=true (the strict // probe: empty dir with rows is suspicious). seed_row(&mut conn, 2, "whatever.jpg", Some(1), Some("exif"));