blob: c9d72a99594366afe245d96ef7c74d51f75b2875 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
pub mod common;
use actualbudget_queries::actualbudget_transactions::{get_all_actualbudget_transactions, get_first_actualbudget_transaction_date};
use common::{db_url::DB_URL, get_reference_data::{get_accounts, get_categories}, transaction_matchers::get_transaction_matchers};
use diesel::{Connection, SqliteConnection};
#[test]
fn given_test_database_when_get_all_transactions_then_return_transactions() {
let connection = &mut SqliteConnection::establish(DB_URL).unwrap();
let accounts = get_accounts(connection);
let categories = get_categories(connection);
let transactions = get_all_actualbudget_transactions(connection);
assert!(transactions.is_ok());
let transactions = transactions.unwrap();
let transaction_matchers = get_transaction_matchers();
assert_eq!(transaction_matchers.len(), transactions.len());
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);
}
}
#[test]
fn given_test_database_when_get_first_transaction_date_then_return_01_aug_2024() {
let connection = &mut SqliteConnection::establish(DB_URL).unwrap();
let date = get_first_actualbudget_transaction_date(connection);
assert!(date.is_ok());
let date = date.unwrap();
assert_eq!("01", date.day());
assert_eq!("08", date.month());
assert_eq!("2024", date.year());
}
|