test(filename_audit): seed library 2 before its image_exif row (#151) #154

Merged
cameron merged 1 commits from fix/filename-audit-test-fk into master 2026-09-30 01:53:21 +00:00
2 changed files with 15 additions and 1 deletions

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"));