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 <noreply@anthropic.com>
This commit is contained in:
Cameron CordesandClaude Opus 5.5 committed 2026-09-29 21:31:53 -04:00
1 parent 053314137c
commit 8a5a7c19d7
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ fn main() -> anyhow::Result<()> {
&& let base = PathBuf::from(base) && let base = PathBuf::from(base)
&& !libraries && !libraries
.iter() .iter()
.any(|l| PathBuf::from(&l.root_path) == base) .any(|l| std::path::Path::new(&l.root_path) == base)
{ {
eprintln!( eprintln!(
"note: BASE_PATH ({}) does not match any library root; auditing the library table", "note: BASE_PATH ({}) does not match any library root; auditing the library table",
+14
View File
@@ -484,6 +484,20 @@ mod tests {
// missing_root is never created -> probe fails. // missing_root is never created -> probe fails.
let mut conn = migrated_conn(); 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 // Give the offline library a row so had_data=true (the strict
// probe: empty dir with rows is suspicious). // probe: empty dir with rows is suspicious).
seed_row(&mut conn, 2, "whatever.jpg", Some(1), Some("exif")); seed_row(&mut conn, 2, "whatever.jpg", Some(1), Some("exif"));