diff --git a/src-tauri/src/database/profile_db.rs b/src-tauri/src/database/profile_db.rs index 9614d39..199eb83 100644 --- a/src-tauri/src/database/profile_db.rs +++ b/src-tauri/src/database/profile_db.rs @@ -851,6 +851,30 @@ mod tests { } } + #[test] + fn a_profile_from_v0_15_to_v0_17_gets_its_history_and_nothing_else() { + // State F: created with the current consolidated schema, before #390 + // wrote a history. Nothing to apply, so no copy either; the flag is + // still repaired. + let dir = unique_dir("state-f"); + let path = create_db(&dir, SECONDARY, &[crate::database::CONSOLIDATED_SCHEMA]); + let category = seed_user_rows(&open(&path)); + + let report = prepare_at(&path, SECONDARY, &migrations()).unwrap(); + + assert_eq!(report.catch_up_error, None); + let done = report.catch_up.unwrap(); + assert_eq!(done.floor, Some(17)); + assert_eq!(done.recorded, versions(1, max_version())); + assert!(done.applied.is_empty()); + assert_eq!(done.backup_file, None); + assert_eq!(report.repaired_flags, 1); + let conn = open(&path); + assert_history_complete(&conn, "state F"); + assert_eq!(count(&conn, "SELECT category_id FROM transactions"), category); + assert!(!dir.join(MIGRATION_BACKUP_DIR).exists()); + } + #[test] fn the_bilan_data_of_a_v0_9_profile_is_converted() { for state in released_states().into_iter().filter(|s| s.floor == 10) {