diff options
| author | Joe Carstairs <me@joeac.net> | 2024-11-30 19:25:21 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2024-11-30 19:25:21 +0000 |
| commit | 7c25ed2ba4be71b9bbed1f68908e39f4a5c4a2c9 (patch) | |
| tree | 93734d966c086002ef57da310b2a6fb128e29d2e /rust/actualbudget_queries/tests | |
| parent | c08232cfd2bfd4b700f2eb18aafc90df8291f8a5 (diff) | |
Fixes AB transaction query tests in light of ActualbudgetDate.to_iso() change
Diffstat (limited to 'rust/actualbudget_queries/tests')
| -rw-r--r-- | rust/actualbudget_queries/tests/actualbudget_transactions.rs | 7 | ||||
| -rw-r--r-- | rust/actualbudget_queries/tests/common/transaction_matchers.rs | 25 |
2 files changed, 18 insertions, 14 deletions
diff --git a/rust/actualbudget_queries/tests/actualbudget_transactions.rs b/rust/actualbudget_queries/tests/actualbudget_transactions.rs index ee05daa..c9d72a9 100644 --- a/rust/actualbudget_queries/tests/actualbudget_transactions.rs +++ b/rust/actualbudget_queries/tests/actualbudget_transactions.rs @@ -16,8 +16,11 @@ fn given_test_database_when_get_all_transactions_then_return_transactions() { let transactions = transactions.unwrap(); let transaction_matchers = get_transaction_matchers(); assert_eq!(transaction_matchers.len(), transactions.len()); - for transaction_matcher in transaction_matchers { - assert!(transactions.iter().any(|t| transaction_matcher(t, &accounts, &categories))); + for transaction in transactions { + let any_match = transaction_matchers.iter().any(|transaction_matcher| + transaction_matcher(&transaction, &accounts, &categories) + ); + assert!(any_match, "no match found for transaction {:?}", transaction); } } diff --git a/rust/actualbudget_queries/tests/common/transaction_matchers.rs b/rust/actualbudget_queries/tests/common/transaction_matchers.rs index 9613b3f..2620da5 100644 --- a/rust/actualbudget_queries/tests/common/transaction_matchers.rs +++ b/rust/actualbudget_queries/tests/common/transaction_matchers.rs @@ -53,7 +53,7 @@ fn matches_bank_account_initial_transaction( .. } => *account_id == bank_account_id && *category_id == starting_balances_category_id - && date.to_iso() == "2024-08-01", + && date.to_iso().get(0..10) == Some("2024-08-01"), _ => false, } } @@ -87,7 +87,7 @@ fn matches_cash_account_initial_transaction( .. } => *account_id == bank_account_id && *category_id == starting_balances_category_id - && date.to_iso() == "2024-08-01", + && date.to_iso().get(0..10) == Some("2024-08-01"), _ => false, } } @@ -121,10 +121,11 @@ fn matches_income_transaction( date, notes: Some(notes), .. - } => *account_id == bank_account_id - && *category_id == Some(income_category_id) - && date.to_iso() == format!("2024-{}-21", month) - && *notes == String::from("Salary"), + } => + *account_id == bank_account_id + && *category_id == Some(income_category_id) + && date.to_iso().get(0..10) == Some(format!("2024-{}-21", month).as_str()) + && *notes == String::from("Salary"), _ => false, } } @@ -159,7 +160,7 @@ fn matches_food_transaction( .. } => *account_id == bank_account_id && *category_id == Some(income_category_id) - && date.to_iso() == format!("2024-{}-08", month), + && date.to_iso().get(0..10) == Some(format!("2024-{}-08", month).as_str()), _ => false, } } @@ -186,7 +187,7 @@ fn matches_category_transfer_parent_transaction( date, .. } => *account_id == category_transfers_account_id - && date.to_iso() == "2024-10-23", + && date.to_iso().get(0..10) == Some("2024-10-23"), _ => false, } } @@ -220,7 +221,7 @@ fn matches_category_transfer_child_out_transaction( .. } => *account_id == category_transfers_account_id && *category_id == savings_category_id - && date.to_iso() == "2024-10-23", + && date.to_iso().get(0..10) == Some("2024-10-23"), _ => false, } } @@ -254,7 +255,7 @@ fn matches_category_transfer_child_in_transaction( .. } => *account_id == category_transfers_account_id && *category_id == savings_category_id - && date.to_iso() == "2024-10-23", + && date.to_iso().get(0..10) == Some("2024-10-23"), _ => false, } } @@ -281,7 +282,7 @@ fn matches_account_transfer_out_transaction( date, .. } => *account_id == bank_account_id - && date.to_iso() == "2024-09-10", + && date.to_iso().get(0..10) == Some("2024-09-10"), _ => false, } } @@ -308,7 +309,7 @@ fn matches_account_transfer_in_transaction( date, .. } => *account_id == cash_account_id - && date.to_iso() == "2024-09-10", + && date.to_iso().get(0..10) == Some("2024-09-10"), _ => false, } } |
