Refactored src and dst account to just account in preparation for a "counter party", instead of a full account.

This commit is contained in:
2026-10-03 20:33:13 +02:00
parent 221c38d364
commit 896b192c01
29 changed files with 535 additions and 422 deletions
+22 -9
View File
@@ -119,9 +119,15 @@ where
fn classify_delete_error(error: DatabaseError) -> RepositoryError {
match &error {
DatabaseError::ForeignKeyViolation {
constraint:
Constraint::RecurringTransactionSourceAccount
| Constraint::RecurringTransactionDestinationAccount,
constraint: Constraint::TransactionAccount,
..
} => RepositoryError::ReferenceViolation {
relation: ReferenceRelation::Transaction,
kind: ReferenceViolationKind::StillReferenced,
source: error,
},
DatabaseError::ForeignKeyViolation {
constraint: Constraint::RecurringTransactionAccount,
..
} => RepositoryError::ReferenceViolation {
relation: ReferenceRelation::RecurringTransaction,
@@ -162,7 +168,7 @@ mod tests {
#[test]
fn classifies_account_delete_foreign_key_constraint() {
let error = classify_delete_error(foreign_key_violation(
Constraint::RecurringTransactionSourceAccount,
Constraint::RecurringTransactionAccount,
));
assert!(matches!(
&error,
@@ -172,16 +178,24 @@ mod tests {
..
}
));
}
let database_error = std::error::Error::source(&error).unwrap();
let sqlx_error = std::error::Error::source(database_error).unwrap();
assert!(sqlx_error.to_string().contains("test database cause"));
#[test]
fn classifies_transaction_account_delete_foreign_key_constraint() {
let error = classify_delete_error(foreign_key_violation(Constraint::TransactionAccount));
assert!(matches!(
error,
RepositoryError::ReferenceViolation {
relation: ReferenceRelation::Transaction,
kind: ReferenceViolationKind::StillReferenced,
..
}
));
}
#[test]
fn keeps_unknown_account_delete_foreign_keys_generic() {
let error = classify_delete_error(foreign_key_violation(Constraint::Unnamed));
assert!(matches!(error, RepositoryError::Database(_)));
}
@@ -197,7 +211,6 @@ mod tests {
let row = row();
let id = row.id;
let account = decode(row).unwrap();
assert_eq!(account.id, id);
assert_eq!(account.name, "Savings");
}