From 23f5f78f8781c9c95031adab1b1404de9a399d7b Mon Sep 17 00:00:00 2001 From: Rusty Pickle Date: Sun, 12 Oct 2025 12:03:52 +0600 Subject: [PATCH 1/2] Fix not working offline --- tui/Cargo.toml | 2 +- tui/src/page_handler/initializer.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tui/Cargo.toml b/tui/Cargo.toml index 03da246..3075cad 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rex-tui" -version = "0.2.0" +version = "0.2.1" edition = "2024" authors = ["TheRustyPickle "] readme = "../README.md" diff --git a/tui/src/page_handler/initializer.rs b/tui/src/page_handler/initializer.rs index f2f8bb6..89c724a 100644 --- a/tui/src/page_handler/initializer.rs +++ b/tui/src/page_handler/initializer.rs @@ -50,7 +50,7 @@ pub fn initialize_app( } } - let new_version = check_version()?; + let new_version = check_version().unwrap_or_default(); if let Err(e) = migrate_config(old_db_path) { println!("Failed to migrate config. Error: {e:?}"); From fc8f40a8b8225aee96be4ef70a5d675e1cebad9b Mon Sep 17 00:00:00 2001 From: Rusty Pickle Date: Sun, 12 Oct 2025 12:04:45 +0600 Subject: [PATCH 2/2] Remove old tests --- .env | 2 - tests_old/activity.rs | 387 ---------------------- tests_old/autofiller.rs | 188 ----------- tests_old/balance.rs | 343 -------------------- tests_old/changes.rs | 105 ------ tests_old/chart.rs | 233 -------------- tests_old/common.rs | 20 -- tests_old/db_creation.rs | 102 ------ tests_old/db_updates.rs | 126 -------- tests_old/home.rs | 259 --------------- tests_old/lerp.rs | 32 -- tests_old/stepper.rs | 587 ---------------------------------- tests_old/summary.rs | 513 ------------------------------ tests_old/tx.rs | 281 ---------------- tests_old/tx_data.rs | 670 --------------------------------------- tests_old/tx_method.rs | 50 --- tests_old/ui_states.rs | 85 ----- tests_old/utils.rs | 154 --------- tests_old/verifier.rs | 262 --------------- tui/Cargo.toml | 2 +- 20 files changed, 1 insertion(+), 4400 deletions(-) delete mode 100644 .env delete mode 100644 tests_old/activity.rs delete mode 100644 tests_old/autofiller.rs delete mode 100644 tests_old/balance.rs delete mode 100644 tests_old/changes.rs delete mode 100644 tests_old/chart.rs delete mode 100644 tests_old/common.rs delete mode 100644 tests_old/db_creation.rs delete mode 100644 tests_old/db_updates.rs delete mode 100644 tests_old/home.rs delete mode 100644 tests_old/lerp.rs delete mode 100644 tests_old/stepper.rs delete mode 100644 tests_old/summary.rs delete mode 100644 tests_old/tx.rs delete mode 100644 tests_old/tx_data.rs delete mode 100644 tests_old/tx_method.rs delete mode 100644 tests_old/ui_states.rs delete mode 100644 tests_old/utils.rs delete mode 100644 tests_old/verifier.rs diff --git a/.env b/.env deleted file mode 100644 index 70f76cf..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -DATABASE_URL="sqlite://v2.sqlite" - diff --git a/tests_old/activity.rs b/tests_old/activity.rs deleted file mode 100644 index c55845c..0000000 --- a/tests_old/activity.rs +++ /dev/null @@ -1,387 +0,0 @@ -extern crate rex_tui; -use chrono::{Datelike, Local}; -use rex_tui::db::YEARS; -use rex_tui::page_handler::{ActivityType, DateType}; -use rex_tui::tx_handler::*; -use rex_tui::utility::{ - add_new_activity, add_new_activity_tx, get_all_activities, get_search_data, switch_tx_index, -}; -use rusqlite::Connection; -use std::fs; - -use crate::common::create_test_db; - -mod common; - -fn add_dummy_tx(conn: &mut Connection) { - let mut tx_data = TxData { - date: "2022-08-19".to_string(), - details: "Car expense".to_string(), - from_method: "Super Special Bank".to_string(), - to_method: String::new(), - amount: "100.00".to_string(), - tx_type: "Expense".to_string(), - tags: "Car".to_string(), - editing_tx: false, - autofill: String::new(), - id_num: 0, - current_index: 0, - tx_status: Vec::new(), - }; - - tx_data.add_tx(conn).unwrap(); - - tx_data.details = "Edited Car expense".to_string(); - - tx_data.editing_tx = true; - tx_data.id_num = 1; - - tx_data.add_tx(conn).unwrap(); - - let mut tx_data_2 = TxData { - date: "2022-08-19".to_string(), - details: "House expense".to_string(), - from_method: "Cash Cow".to_string(), - to_method: String::new(), - amount: "500.00".to_string(), - tx_type: "Expense".to_string(), - tags: "House".to_string(), - editing_tx: false, - autofill: String::new(), - id_num: 0, - current_index: 0, - tx_status: Vec::new(), - }; - - tx_data_2.add_tx(conn).unwrap(); - - let all_texts: Vec = vec![ - tx_data.date.clone(), - tx_data.details.clone(), - tx_data.from_method.clone(), - tx_data.amount.clone(), - tx_data.tx_type.clone(), - tx_data.tags.clone(), - "1".to_string(), - ]; - - let all_texts_2: Vec = vec![ - tx_data_2.date.clone(), - tx_data_2.details.clone(), - tx_data_2.from_method.clone(), - tx_data_2.amount.clone(), - tx_data_2.tx_type.clone(), - tx_data_2.tags.clone(), - ]; - - switch_tx_index(1, 2, &all_texts, &all_texts_2, conn); - - let mut tx_data = TxData { - date: "2022-08-19".to_string(), - details: "Transfer".to_string(), - from_method: "Super Special Bank".to_string(), - to_method: String::from("Cash Cow"), - amount: "100.00".to_string(), - tx_type: "Transfer".to_string(), - tags: "Car".to_string(), - editing_tx: false, - autofill: String::new(), - id_num: 0, - current_index: 0, - tx_status: Vec::new(), - }; - - tx_data.add_tx(conn).unwrap(); - - let mut tx_data_2 = TxData { - date: "2022-08-19".to_string(), - details: "Transfer".to_string(), - from_method: "Cash Cow".to_string(), - to_method: String::from("Super Special Bank"), - amount: "500.00".to_string(), - tx_type: "Transfer".to_string(), - tags: "House".to_string(), - editing_tx: false, - autofill: String::new(), - id_num: 0, - current_index: 0, - tx_status: Vec::new(), - }; - - tx_data_2.add_tx(conn).unwrap(); - - let all_texts: Vec = vec![ - tx_data.date.clone(), - tx_data.details.clone(), - format!("{} to {}", tx_data.from_method, tx_data.to_method), - tx_data.amount.clone(), - tx_data.tx_type.clone(), - tx_data.tags.clone(), - "1".to_string(), - ]; - - let all_texts_2: Vec = vec![ - tx_data_2.date.clone(), - tx_data_2.details.clone(), - format!("{} to {}", tx_data_2.from_method, tx_data_2.to_method), - tx_data_2.amount.clone(), - tx_data_2.tx_type.clone(), - tx_data_2.tags.clone(), - ]; - - switch_tx_index(3, 4, &all_texts, &all_texts_2, conn); - - get_search_data("", "Selling", "", "", "", "", "", &DateType::Exact, conn); - get_search_data( - "", - "Selling", - "Super Special Bank", - "", - "", - "", - "", - &DateType::Exact, - conn, - ); - - let activity_num = add_new_activity(ActivityType::DeleteTX(Some(1)), conn); - add_new_activity_tx(&all_texts, activity_num, conn); -} - -#[test] -fn activity_test() { - let file_name = "activity_test.sqlite"; - let mut conn = create_test_db(file_name); - - let year = Local::now().year().to_string(); - let month = Local::now().month() as usize; - - let year_index = YEARS.iter().position(|y| y == &year).unwrap(); - - let month_index = month - 1; - - add_dummy_tx(&mut conn); - - let activities = get_all_activities(1, 0, &conn); - - assert_eq!(activities.0.len(), 0); - assert_eq!(activities.1.len(), 0); - - let activities = get_all_activities(month_index, year_index, &conn); - - assert_eq!(activities.0.len(), 10); - assert_eq!(activities.1.len(), 10); - - for details in activities.0 { - match details.activity_type { - ActivityType::NewTX => { - let activity_num = details.activity_num(); - let activity_txs = activities.1.get(&activity_num).unwrap(); - assert_eq!(activity_txs.len(), 1); - - assert_eq!(details.description, details.activity_type.to_details()); - - let tx = &activity_txs[0]; - - let expected_date = "19-08-2022".to_string(); - let expected_details = [ - "Car expense".to_string(), - "House expense".to_string(), - "Transfer".to_string(), - ]; - let expected_from_method = [ - "Super Special Bank".to_string(), - "Cash Cow".to_string(), - "Super Special Bank to Cash Cow".to_string(), - "Cash Cow to Super Special Bank".to_string(), - ]; - let expected_amount = ["100.00".to_string(), "500.00".to_string()]; - let expected_tx_type = ["Expense".to_string(), "Transfer".to_string()]; - let expected_tags = ["Car".to_string(), "House".to_string()]; - - assert_eq!(tx.date, expected_date); - assert!(expected_details.contains(&tx.details)); - assert!(expected_from_method.contains(&tx.tx_method)); - assert!(expected_amount.contains(&tx.amount)); - assert!(expected_tx_type.contains(&tx.tx_type)); - assert!(expected_tags.contains(&tx.tags)); - } - ActivityType::EditTX(_) => { - let activity_num = details.activity_num(); - let activity_txs = activities.1.get(&activity_num).unwrap(); - assert_eq!(activity_txs.len(), 2); - - assert_eq!( - details.description, - ActivityType::EditTX(Some(1)).to_details() - ); - - let expected_date = "19-08-2022".to_string(); - let expected_details = [ - "Car expense".to_string(), - "Edited Car expense".to_string(), - "Transfer".to_string(), - ]; - let expected_from_method = "Super Special Bank".to_string(); - let expected_amount = "100.00".to_string(); - let expected_tx_type = "Expense".to_string(); - let expected_tags = "Car".to_string(); - - activity_txs.iter().enumerate().for_each(|(index, tx)| { - assert_eq!(tx.date, expected_date); - if index == 1 { - assert_eq!(tx.details, expected_details[0]); - } else { - assert_eq!(tx.details, expected_details[1]); - } - assert_eq!(tx.amount, expected_amount); - assert_eq!(tx.tags, expected_tags); - - if tx.tx_type == "Expense" { - assert_eq!(tx.tx_method, expected_from_method); - assert_eq!(tx.tx_type, expected_tx_type); - } else { - let expected_method = [ - "Super Special Bank to Cash Cow".to_string(), - "Cash Cow to Super Special Bank".to_string(), - ]; - assert_eq!(tx.tx_type, "Transfer"); - assert!(expected_method.contains(&tx.tx_method)); - } - }); - } - ActivityType::DeleteTX(_) => { - let activity_num = details.activity_num(); - let activity_txs = activities.1.get(&activity_num).unwrap(); - - assert_eq!(activity_txs.len(), 1); - - assert_eq!( - details.description, - ActivityType::DeleteTX(Some(1)).to_details() - ); - - let tx = &activity_txs[0]; - - let expected_date = "19-08-2022".to_string(); - let expected_details = "Transfer".to_string(); - let expected_from_method = "Super Special Bank to Cash Cow".to_string(); - let expected_amount = "100.00".to_string(); - let expected_tx_type = "Transfer".to_string(); - let expected_tags = "Car".to_string(); - - assert_eq!(tx.date, expected_date); - assert_eq!(tx.details, expected_details); - assert_eq!(tx.tx_method, expected_from_method); - assert_eq!(tx.amount, expected_amount); - assert_eq!(tx.tx_type, expected_tx_type); - assert_eq!(tx.tags, expected_tags); - } - ActivityType::IDNumSwap(_, _) => { - let activity_num = details.activity_num(); - let activity_txs = activities.1.get(&activity_num).unwrap(); - - assert_eq!(activity_txs.len(), 2); - - if activity_num < 5 { - assert_eq!( - details.description, - ActivityType::IDNumSwap(Some(1), Some(2)).to_details() - ); - - let expected_date = "19-08-2022".to_string(); - let expected_amount = "100.00".to_string(); - let expected_tags = "Car".to_string(); - let expected_details = "Edited Car expense".to_string(); - let expected_from_method = "Super Special Bank".to_string(); - let expected_tx_type = "Expense".to_string(); - - assert_eq!(activity_txs[0].date, expected_date); - assert_eq!(activity_txs[0].details, expected_details); - assert_eq!(activity_txs[0].tx_method, expected_from_method); - assert_eq!(activity_txs[0].amount, expected_amount); - assert_eq!(activity_txs[0].tx_type, expected_tx_type); - assert_eq!(activity_txs[0].tags, expected_tags); - assert_eq!(activity_txs[0].id_num, "2".to_string()); - - let expected_date = "19-08-2022".to_string(); - let expected_details = "House expense".to_string(); - let expected_from_method = "Cash Cow".to_string(); - let expected_amount = "500.00".to_string(); - let expected_tx_type = "Expense".to_string(); - let expected_tags = "House".to_string(); - - assert_eq!(activity_txs[1].date, expected_date); - assert_eq!(activity_txs[1].details, expected_details); - assert_eq!(activity_txs[1].tx_method, expected_from_method); - assert_eq!(activity_txs[1].amount, expected_amount); - assert_eq!(activity_txs[1].tx_type, expected_tx_type); - assert_eq!(activity_txs[1].tags, expected_tags); - assert_eq!(activity_txs[1].id_num, "1".to_string()); - } else { - assert_eq!( - details.description, - ActivityType::IDNumSwap(Some(3), Some(4)).to_details() - ); - - let expected_date = "19-08-2022".to_string(); - let expected_amount = "100.00".to_string(); - let expected_tags = "Car".to_string(); - let expected_details = "Transfer".to_string(); - let expected_from_method = "Super Special Bank to Cash Cow".to_string(); - let expected_tx_type = "Transfer".to_string(); - - assert_eq!(activity_txs[0].date, expected_date); - assert_eq!(activity_txs[0].details, expected_details); - assert_eq!(activity_txs[0].tx_method, expected_from_method); - assert_eq!(activity_txs[0].amount, expected_amount); - assert_eq!(activity_txs[0].tx_type, expected_tx_type); - assert_eq!(activity_txs[0].tags, expected_tags); - assert_eq!(activity_txs[0].id_num, "4".to_string()); - - let expected_date = "19-08-2022".to_string(); - let expected_details = "Transfer".to_string(); - let expected_from_method = "Cash Cow to Super Special Bank".to_string(); - let expected_amount = "500.00".to_string(); - let expected_tx_type = "Transfer".to_string(); - let expected_tags = "House".to_string(); - - assert_eq!(activity_txs[1].date, expected_date); - assert_eq!(activity_txs[1].details, expected_details); - assert_eq!(activity_txs[1].tx_method, expected_from_method); - assert_eq!(activity_txs[1].amount, expected_amount); - assert_eq!(activity_txs[1].tx_type, expected_tx_type); - assert_eq!(activity_txs[1].tags, expected_tags); - assert_eq!(activity_txs[1].id_num, "3".to_string()); - } - } - ActivityType::SearchTX(_) => { - let activity_num = details.activity_num(); - let activity_txs = activities.1.get(&activity_num).unwrap(); - - let tx = &activity_txs[0]; - assert_eq!(activity_txs.len(), 1); - - let searched_with = if tx.tx_method.is_empty() { 1 } else { 2 }; - - assert_eq!( - details.description, - ActivityType::SearchTX(Some(searched_with)).to_details() - ); - - let expected_details = "Selling".to_string(); - let expected_from_method = [String::new(), "Super Special Bank".to_string()]; - - assert_eq!(tx.date, String::new()); - assert_eq!(tx.details, expected_details); - assert!(expected_from_method.contains(&tx.tx_method)); - assert_eq!(tx.amount, String::new()); - assert_eq!(tx.tx_type, String::new()); - assert_eq!(tx.tags, String::new()); - } - } - } - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/autofiller.rs b/tests_old/autofiller.rs deleted file mode 100644 index afcf220..0000000 --- a/tests_old/autofiller.rs +++ /dev/null @@ -1,188 +0,0 @@ -extern crate rex_tui; -use rex_tui::page_handler::TxTab; -use rex_tui::tx_handler::*; -use rex_tui::utility::traits::AutoFiller; -use rusqlite::Connection; -use std::fs; - -use crate::common::create_test_db; - -mod common; - -struct Testing { - data: Vec, - expected: Vec, -} -impl AutoFiller for Testing {} - -fn add_dummy_tx(conn: &mut Connection) { - add_tx( - "2022-08-19", - "Car expense", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Food cost", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Selling goods", - "Super Special Bank", - "200.00", - "Income", - "Goods", - None, - conn, - ) - .unwrap(); -} - -#[test] -fn autofiller_test() { - let file_name = "autofiller_test.sqlite"; - let mut conn = create_test_db(file_name); - - let data = vec![ - "car", - "expense", - "sll", - "f o o d", - "Selling goods", - "coast", - "r ex", - "", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let expected = vec![ - "Car expense", - "Car expense", - "Selling goods", - "Food cost", - "", - "Food cost", - "Car expense", - "", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let test_data = Testing { data, expected }; - - // Nothing to take suggestion from so empty string as autofiller - for i in 0..test_data.data.len() { - let result = test_data.autofill_details(&test_data.data[i], &conn); - assert_eq!(result, String::new()); - } - - add_dummy_tx(&mut conn); - - for i in 0..test_data.data.len() { - let result = test_data.autofill_details(&test_data.data[i], &conn); - assert_eq!(result, test_data.expected[i]); - } - - let data = vec![ - "sup", "cash", "CoW", "Cis", "sup", "bank", "CaSh CoW", "Cash Cow", "", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let expected = vec![ - "Super Special Bank", - "Cash Cow", - "Cash Cow", - "Cash Cow", - "Super Special Bank", - "Super Special Bank", - "Cash Cow", - "", - "", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let test_data = Testing { data, expected }; - - for i in 0..test_data.data.len() { - let result = test_data.autofill_tx_method(&test_data.data[i], &conn); - assert_eq!(result, test_data.expected[i]); - } - - let data = vec![ - "foo", "goo", "fod", "gid", "rac", "Car", "", "Food,", "Food, Go", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let expected = vec!["Food", "Goods", "Food", "Goods", "Car", "", "", "", "Goods"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let test_data = Testing { data, expected }; - - for i in 0..test_data.data.len() { - let result = test_data.autofill_tags(&test_data.data[i], &conn); - assert_eq!(result, test_data.expected[i]); - } - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn tx_data_autofiller() { - let file_name = "autofiller_test_2.sqlite"; - let mut conn = create_test_db(file_name); - add_dummy_tx(&mut conn); - - let mut tx_data = TxData::custom("", "Food", "Super", "Cash", "", "", "Car, fo", 1); - - tx_data.check_autofill(&TxTab::Details, &conn); - assert_eq!(tx_data.autofill, "Food cost"); - tx_data.accept_autofill(&TxTab::Details); - assert_eq!(tx_data.details, "Food cost"); - - tx_data.check_autofill(&TxTab::FromMethod, &conn); - assert_eq!(tx_data.autofill, "Super Special Bank"); - tx_data.accept_autofill(&TxTab::FromMethod); - assert_eq!(tx_data.from_method, "Super Special Bank"); - - tx_data.check_autofill(&TxTab::ToMethod, &conn); - assert_eq!(tx_data.autofill, "Cash Cow"); - tx_data.accept_autofill(&TxTab::ToMethod); - assert_eq!(tx_data.to_method, "Cash Cow"); - - tx_data.check_autofill(&TxTab::Tags, &conn); - assert_eq!(tx_data.autofill, "Food"); - tx_data.accept_autofill(&TxTab::Tags); - assert_eq!(tx_data.tags, "Car, Food"); - - tx_data.check_autofill(&TxTab::Amount, &conn); - assert_eq!(tx_data.autofill, ""); - tx_data.accept_autofill(&TxTab::Details); - assert_eq!(tx_data.amount, ""); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/balance.rs b/tests_old/balance.rs deleted file mode 100644 index 8f638c3..0000000 --- a/tests_old/balance.rs +++ /dev/null @@ -1,343 +0,0 @@ -extern crate rex_tui; -use chrono::{Duration, naive::NaiveDate}; -use rex_tui::tx_handler::*; -use rex_tui::utility::*; -use rusqlite::Result as sqlResult; -use std::collections::HashMap; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_last_balances_1() { - let file_name = "last_balances_1.sqlite"; - let conn = create_test_db(file_name); - let data = get_last_balances(&conn); - let expected_data = vec!["0".to_string(), "0".to_string()]; - conn.close().unwrap(); - - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_last_balances_2() { - let file_name = "last_balances_2.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "159.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow", - "159.19", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let data = get_last_balances(&conn); - let expected_data = vec!["-159".to_string(), "159.19".to_string()]; - - delete_tx(1, &mut conn).unwrap(); - - let data_2 = get_last_balances(&conn); - let expected_data_2 = vec!["0".to_string(), "159.19".to_string()]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); - assert_eq!(data_2, expected_data_2); -} - -#[test] -fn check_last_balances_3() { - let file_name = "last_balances_3.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank to Cash Cow", - "159.00", - "Transfer", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow to Super Special Bank", - "159.00", - "Transfer", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let data = get_last_balances(&conn); - let expected_data = vec!["0".to_string(), "0".to_string()]; - - delete_tx(1, &mut conn).unwrap(); - - let data_2 = get_last_balances(&conn); - let expected_data_2 = vec!["159".to_string(), "-159".to_string()]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); - assert_eq!(data_2, expected_data_2); -} - -#[test] -fn check_last_month_balance_1() { - let file_name = "last_month_balance_1.sqlite"; - let conn = create_test_db(file_name); - let tx_methods = get_all_tx_methods(&conn); - - let data = get_last_time_balance(6, 1, &tx_methods, &conn); - let expected_data = HashMap::from([ - ("Super Special Bank".to_string(), 0.0), - ("Cash Cow".to_string(), 0.0), - ]); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_last_balance_id() { - let file_name = "last_balance_id.sqlite"; - let conn = create_test_db(file_name); - - let data = get_last_balance_id(&conn); - let expected_data: sqlResult = Ok(193); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_last_month_balance_2() { - let file_name = "last_month_balance_2.sqlite"; - let mut conn = create_test_db(file_name); - let tx_methods = get_all_tx_methods(&conn); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-09-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-10-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let data_1 = get_last_time_balance(8, 0, &tx_methods, &conn); - let expected_data_1 = HashMap::from([ - ("Cash Cow".to_string(), 100.0), - ("Super Special Bank".to_string(), 200.0), - ]); - - delete_tx(1, &mut conn).unwrap(); - delete_tx(2, &mut conn).unwrap(); - - let data_2 = get_last_time_balance(10, 3, &tx_methods, &conn); - let expected_data_2 = HashMap::from([ - ("Cash Cow".to_string(), 0.0), - ("Super Special Bank".to_string(), 300.0), - ]); - - add_tx( - "2028-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2025-09-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2025-10-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let data_3 = get_last_time_balance(10, 4, &tx_methods, &conn); - let expected_data_3 = HashMap::from([ - ("Cash Cow".to_string(), 0.0), - ("Super Special Bank".to_string(), 500.0), - ]); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data_1, expected_data_1); - assert_eq!(data_2, expected_data_2); - assert_eq!(data_3, expected_data_3); -} - -#[test] -#[ignore] -fn check_balance_all_day() { - let file_name = "check_balance_all_day.sqlite"; - let mut conn = create_test_db(file_name); - let tx_methods = get_all_tx_methods(&conn); - - let mut current_date = NaiveDate::parse_from_str("2022-01-01", "%Y-%m-%d").unwrap(); - let ending_date = NaiveDate::parse_from_str("2037-12-31", "%Y-%m-%d").unwrap(); - - let mut total_days = 0; - let mut total_amount = 0; - - let details = "Test Transaction"; - let amount = "1.0"; - let tx_method = "Super Special Bank"; - let tx_type = "Income"; - - loop { - if current_date > ending_date { - break; - } - add_tx( - ¤t_date.to_string(), - details, - tx_method, - amount, - tx_type, - "Unknown", - None, - &mut conn, - ) - .unwrap(); - current_date += Duration::days(28); - total_amount += 1; - total_days += 1; - } - - let data = get_last_balances(&conn); - let expected = vec![total_amount.to_string(), "0".to_string()]; - assert_eq!(data, expected); - - let mut delete_id_num = total_days; - - loop { - if delete_id_num == 0 { - break; - } - delete_tx(delete_id_num, &mut conn).unwrap(); - delete_id_num -= 1; - } - - let data_1 = get_last_balances(&conn); - let data_2 = get_last_time_balance(12, 3, &tx_methods, &conn); - - let expected_data_1 = vec!["0".to_string(), "0".to_string()]; - let mut expected_data_2 = HashMap::new(); - for i in data_2.keys() { - expected_data_2.insert(i.to_string(), 0.0); - } - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data_1, expected_data_1); - assert_eq!(data_2, expected_data_2); -} diff --git a/tests_old/changes.rs b/tests_old/changes.rs deleted file mode 100644 index 71256d0..0000000 --- a/tests_old/changes.rs +++ /dev/null @@ -1,105 +0,0 @@ -extern crate rex_tui; -use rex_tui::tx_handler::*; -use rex_tui::utility::*; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_empty_changes() { - let file_name = "empty_changes.sqlite"; - let conn = create_test_db(file_name); - let data = get_empty_changes(&conn); - conn.close().unwrap(); - - fs::remove_file(file_name).unwrap(); - - assert_eq!( - data, - vec![ - "Changes".to_string(), - "0.00".to_string(), - "0.00".to_string() - ] - ); -} - -#[test] -fn check_getting_all_changes() { - let file_name = "getting_changes_1.sqlite"; - let conn = create_test_db(file_name); - let data = get_all_changes(5, 6, &conn); - let empty_data: Vec> = Vec::new(); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, empty_data); -} - -#[test] -fn check_getting_all_changes_2() { - let file_name = "getting_changes_2.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "159.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow", - "159.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-05-01", - "Testing transaction", - "Cash Cow", - "753.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - // This is the index of the interface. year 0 = 2022, month 0 = January - let data_1 = get_all_changes(6, 0, &conn); - let expected_data_1: Vec> = vec![ - vec!["↓159.00".to_string(), "0.00".to_string()], - vec!["0.00".to_string(), "↓159.00".to_string()], - ]; - - let another_data = get_all_changes(4, 0, &conn); - - let another_expected = vec![vec!["0.00".to_string(), "↓753.00".to_string()]]; - - delete_tx(2, &mut conn).unwrap(); - - let data_2 = get_all_changes(6, 0, &conn); - let expected_data_2: Vec> = vec![vec!["↓159.00".to_string(), "0.00".to_string()]]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data_1, expected_data_1); - assert_eq!(data_2, expected_data_2); - assert_eq!(another_data, another_expected); -} diff --git a/tests_old/chart.rs b/tests_old/chart.rs deleted file mode 100644 index e8d8312..0000000 --- a/tests_old/chart.rs +++ /dev/null @@ -1,233 +0,0 @@ -extern crate rex_tui; -use chrono::NaiveDate; -use rex_tui::chart_page::ChartData; -use rex_tui::page_handler::IndexedData; -use rex_tui::tx_handler::add_tx; -use rusqlite::Connection; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -fn add_dummy_tx(conn: &mut Connection) { - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Testing transaction", - "Super Special Bank", - "200.00", - "Income", - "Food", - None, - conn, - ) - .unwrap(); -} - -#[test] -fn check_chart_date() { - let file_name = "chart_data_1.sqlite"; - let mut conn = create_test_db(file_name); - add_dummy_tx(&mut conn); - - let chart_data = ChartData::new(&conn); - - let mut chart_mode = IndexedData::new_modes(); - - let chart_dates_1 = chart_data.get_all_dates(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_all_dates(&chart_mode, 6, 1); - - let expected_data_1 = Vec::new(); - let expected_data_2 = vec![ - NaiveDate::from_ymd_opt(2023, 7, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 25).unwrap(), - ]; - - assert_eq!(chart_dates_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - chart_mode.next(); - - let chart_dates_1 = chart_data.get_all_dates(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_all_dates(&chart_mode, 6, 1); - - let expected_data_1 = vec![ - NaiveDate::from_ymd_opt(2023, 7, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 25).unwrap(), - ]; - let expected_data_2 = vec![ - NaiveDate::from_ymd_opt(2023, 7, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 25).unwrap(), - ]; - - assert_eq!(chart_dates_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - chart_mode.next(); - - let chart_dates_1 = chart_data.get_all_dates(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_all_dates(&chart_mode, 6, 1); - - let expected_data_1 = vec![ - NaiveDate::from_ymd_opt(2022, 8, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 25).unwrap(), - ]; - let expected_data_2 = vec![ - NaiveDate::from_ymd_opt(2022, 8, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 19).unwrap(), - NaiveDate::from_ymd_opt(2023, 7, 25).unwrap(), - ]; - - assert_eq!(chart_dates_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn check_chart_data() { - let file_name = "chart_data_2.sqlite"; - let mut conn = create_test_db(file_name); - add_dummy_tx(&mut conn); - - let chart_data = ChartData::new(&conn); - - let mut chart_mode = IndexedData::new_modes(); - - let first_tx = [ - "19-08-2022", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - ] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let second_tx = [ - "19-07-2023", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - ] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let third_tx = [ - "25-07-2023", - "Testing transaction", - "Super Special Bank", - "200.00", - "Income", - "Food", - ] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let chart_data_1 = chart_data.get_data(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_data(&chart_mode, 6, 1); - - let expected_data_1 = (Vec::new(), Vec::new()); - - let first_balance = ["-100.00", "-100.00"] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - let second_balance = ["100.00", "-100.00"] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let expected_data_2 = ( - vec![&second_tx, &third_tx], - vec![&first_balance, &second_balance], - ); - - assert_eq!(chart_data_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - chart_mode.next(); - - let chart_data_1 = chart_data.get_data(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_data(&chart_mode, 6, 1); - - let expected_data_1 = ( - vec![&second_tx, &third_tx], - vec![&first_balance, &second_balance], - ); - - let expected_data_2 = ( - vec![&second_tx, &third_tx], - vec![&first_balance, &second_balance], - ); - - assert_eq!(chart_data_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - chart_mode.next(); - - let chart_data_1 = chart_data.get_data(&chart_mode, 1, 1); - let chart_dates_2 = chart_data.get_data(&chart_mode, 6, 1); - - let first_balance = ["-100.00", "0.00"] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - let second_balance = ["-100.00", "-100.00"] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let third_balance = ["100.00", "-100.00"] - .map(std::string::ToString::to_string) - .into_iter() - .collect(); - - let expected_data_1 = ( - vec![&first_tx, &second_tx, &third_tx], - vec![&first_balance, &second_balance, &third_balance], - ); - - let expected_data_2 = ( - vec![&first_tx, &second_tx, &third_tx], - vec![&first_balance, &second_balance, &third_balance], - ); - - assert_eq!(chart_data_1, expected_data_1); - assert_eq!(chart_dates_2, expected_data_2); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/common.rs b/tests_old/common.rs deleted file mode 100644 index 8b950c5..0000000 --- a/tests_old/common.rs +++ /dev/null @@ -1,20 +0,0 @@ -use rex_tui::db::create_db; -use rusqlite::Connection; -use std::fs; - -#[must_use] -pub fn create_test_db(file_name: &str) -> Connection { - if let Ok(metadata) = fs::metadata(file_name) - && metadata.is_file() - { - fs::remove_file(file_name).expect("Failed to delete existing file"); - } - - let mut conn = Connection::open(file_name).unwrap(); - create_db( - &["Super Special Bank".to_string(), "Cash Cow".to_string()], - &mut conn, - ) - .unwrap(); - conn -} diff --git a/tests_old/db_creation.rs b/tests_old/db_creation.rs deleted file mode 100644 index dd467a3..0000000 --- a/tests_old/db_creation.rs +++ /dev/null @@ -1,102 +0,0 @@ -extern crate rex_tui; -use rex_tui::db::{add_new_tx_methods, rename_column, reposition_column}; -use rex_tui::tx_handler::add_tx; -use rex_tui::utility::{get_all_tx_methods, get_last_balances}; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_db_creation() { - let file_name = "test_db_1.sqlite"; - let conn = create_test_db(file_name); - - let paths = fs::read_dir(".").unwrap(); - let mut db_found = false; - for path in paths { - let path = path.unwrap().path().display().to_string(); - if path.contains(file_name) { - db_found = true; - } - } - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert!(db_found); -} - -#[test] -fn check_adding_new_tx_method() { - let file_name = "test_db_2.sqlite"; - let mut conn = create_test_db(file_name); - - let status = add_new_tx_methods(&["test3".to_string(), "test 4".to_string()], &mut conn); - - let tx_methods = get_all_tx_methods(&conn); - let expected_tx_methods = vec![ - "Super Special Bank".to_string(), - "Cash Cow".to_string(), - "test3".to_string(), - "test 4".to_string(), - ]; - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(status, Ok(())); - assert_eq!(expected_tx_methods, tx_methods); -} - -#[test] -fn check_renaming_columns() { - let file_name = "test_db_3.sqlite"; - let mut conn = create_test_db(file_name); - - let status = rename_column("Cash Cow", "testing", &mut conn); - let tx_methods = get_all_tx_methods(&conn); - let expected_tx_methods = vec!["Super Special Bank".to_string(), "testing".to_string()]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(status, Ok(())); - assert_eq!(expected_tx_methods, tx_methods); -} - -#[test] -fn check_repositioning_columns() { - let file_name = "test_db_4.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "159.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let old_last_balances = get_last_balances(&conn); - - let status = reposition_column( - &["Cash Cow".to_string(), "Super Special Bank".to_string()], - &mut conn, - ); - let tx_methods = get_all_tx_methods(&conn); - let expected_tx_methods = vec!["Cash Cow".to_string(), "Super Special Bank".to_string()]; - - let last_balances = get_last_balances(&conn); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(status, Ok(())); - assert_eq!(expected_tx_methods, tx_methods); - assert_eq!(old_last_balances, vec!["159", "0"]); - assert_eq!(last_balances, vec!["0", "159"]); -} diff --git a/tests_old/db_updates.rs b/tests_old/db_updates.rs deleted file mode 100644 index 256a53b..0000000 --- a/tests_old/db_updates.rs +++ /dev/null @@ -1,126 +0,0 @@ -extern crate rex_tui; -use rex_tui::db::{add_tags_column, update_balance_type}; -use rex_tui::utility::{check_old_balance_sql, get_all_tx_columns, get_last_balance_id}; -use rusqlite::Connection; -use std::fs; - -fn check_test_db(file_name: &str) { - if let Ok(metadata) = fs::metadata(file_name) - && metadata.is_file() - { - fs::remove_file(file_name).expect("Failed to delete existing file"); - } -} - -#[test] -fn check_tags_migration() { - let file_name = "db_update_1.sqlite"; - check_test_db(file_name); - let mut conn = Connection::open(file_name).unwrap(); - - conn.execute( - "CREATE TABLE tx_all ( - date TEXT, - details TEXT, - tx_method TEXT, - amount TEXT, - tx_type TEXT, - id_num INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT - );", - [], - ) - .unwrap(); - - let old_columns = get_all_tx_columns(&conn); - add_tags_column(&mut conn).unwrap(); - let new_columns = get_all_tx_columns(&conn); - - let expected_columns = vec![ - "date".to_string(), - "details".to_string(), - "tx_method".to_string(), - "amount".to_string(), - "tx_type".to_string(), - "id_num".to_string(), - "tags".to_string(), - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert!(!old_columns.contains(&"tags".to_string())); - assert_eq!(new_columns, expected_columns); -} - -#[test] -fn check_balance_migration() { - let file_name = "db_update_2.sqlite"; - check_test_db(file_name); - let mut conn = Connection::open(file_name).unwrap(); - - conn.execute( - r#"CREATE TABLE balance_all ( - id_num INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "Super Special Bank" TEXT DEFAULT 0.00, - "Cash Cow" TEXT DEFAULT 0.00 - );"#, - [], - ) - .unwrap(); - - let query = - r#"INSERT INTO balance_all ("Super Special Bank", "Cash Cow") VALUES ("0.00", "0.00")"# - .to_string(); - for _i in 0..49 { - conn.execute(&query, []).unwrap(); - } - - conn.execute( - r#"UPDATE balance_all SET "Super Special Bank" = 200.19, "Cash Cow" = 159.19 WHERE id_num = 49"#, - [], - ) - .unwrap(); - - let query = - r#"SELECT "Super Special Bank", "Cash Cow" FROM balance_all ORDER BY id_num DESC LIMIT 1"#; - - let old_last_balances = conn - .query_row(query, [], |row| { - let final_data: Vec = vec![row.get(0).unwrap(), row.get(1).unwrap()]; - Ok(final_data) - }) - .unwrap(); - - let old_db_status = check_old_balance_sql(&conn); - let old_last_balance_id = get_last_balance_id(&conn).unwrap(); - - update_balance_type(&mut conn).unwrap(); - - let last_balances = conn - .query_row(query, [], |row| { - let balance_1: f64 = row.get(0).unwrap(); - let balance_2: f64 = row.get(1).unwrap(); - Ok(vec![balance_1.to_string(), balance_2.to_string()]) - }) - .unwrap(); - - let db_status = check_old_balance_sql(&conn); - let last_balance_id = get_last_balance_id(&conn).unwrap(); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert!(old_db_status); - assert_eq!(old_last_balance_id, 49); - assert_eq!( - old_last_balances, - vec!["200.19".to_string(), "159.19".to_string()] - ); - - assert!(!db_status); - assert_eq!(last_balance_id, 193); - assert_eq!( - last_balances, - vec!["200.19".to_string(), "159.19".to_string()] - ); -} diff --git a/tests_old/home.rs b/tests_old/home.rs deleted file mode 100644 index 534fee7..0000000 --- a/tests_old/home.rs +++ /dev/null @@ -1,259 +0,0 @@ -extern crate rex_tui; -use rex_tui::home_page::TransactionData; -use rex_tui::tx_handler::add_tx; -use rex_tui::utility::get_all_txs; -use rusqlite::Connection; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -fn add_dummy_tx(conn: &mut Connection) { - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Testing transaction", - "Super Special Bank", - "200.00", - "Income", - "Food", - None, - conn, - ) - .unwrap(); -} - -#[test] -fn test_home_data() { - let file_name = "home_data_1.sqlite"; - let mut conn = create_test_db(file_name); - add_dummy_tx(&mut conn); - - let tx_data_1 = TransactionData::new(1, 1, &conn); - let tx_data_2 = TransactionData::new(6, 1, &conn); - - let is_tx_empty_1 = tx_data_1.is_tx_empty(); - let is_tx_empty_2 = tx_data_2.is_tx_empty(); - - assert!(is_tx_empty_1); - assert!(!is_tx_empty_2); - - let all_tx_1 = tx_data_1.get_txs(); - let all_tx_2 = tx_data_2.get_txs(); - - let expected_data_1: Vec> = Vec::new(); - - let tx_1 = vec![ - "19-07-2023", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - let tx_2 = vec![ - "25-07-2023", - "Testing transaction", - "Super Special Bank", - "200.00", - "Income", - "Food", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - let expected_data_2: Vec> = vec![tx_1, tx_2]; - - assert_eq!(all_tx_1, expected_data_1); - assert_eq!(all_tx_2, expected_data_2); - - let all_changes_1 = tx_data_2.get_changes(0); - let all_changes_2 = tx_data_2.get_changes(1); - let all_balance_1 = tx_data_2.get_balance(0); - let all_balance_2 = tx_data_2.get_balance(1); - - // Tx method changes for that 1 tx - let expected_changes_1: Vec = vec!["Changes", "0.00", "↓100.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - let expected_changes_2: Vec = vec!["Changes", "↑200.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - // Balances are that tx was counted + the total balance combining the first two - let expected_balance_1: Vec = vec!["Balance", "-100.00", "-100.00", "-200.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - let expected_balance_2: Vec = vec!["Balance", "100.00", "-100.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - assert_eq!(all_balance_1, expected_balance_1); - assert_eq!(all_changes_1, expected_changes_1); - assert_eq!(all_balance_2, expected_balance_2); - assert_eq!(all_changes_2, expected_changes_2); - - let last_balance_1 = tx_data_1.get_last_balance(&conn); - let last_balance_2 = tx_data_2.get_last_balance(&conn); - - // Regardless of the month of the TransactionData, the last balance will be the same - let expected_data: Vec<_> = vec!["Balance", "100.00", "-100.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - assert_eq!(last_balance_1, expected_data); - assert_eq!(last_balance_2, expected_data); - - // Id num is incremented by 1 as txs are added - let id_num_1 = tx_data_2.get_id_num(0); - let id_num_2 = tx_data_2.get_id_num(1); - - assert_eq!(id_num_1, 2); - assert_eq!(id_num_2, 3); - - let total_income_1 = tx_data_1.get_total_income(None, &conn); - let total_income_2 = tx_data_2.get_total_income(None, &conn); - - // No tx available within the selected index so 0 balance - let expected_data_1: Vec = vec!["Income", "0.00", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - let expected_data_2: Vec = vec!["Income", "200.00", "0.00", "200.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - assert_eq!(total_income_1, expected_data_1); - assert_eq!(total_income_2, expected_data_2); - - let total_expense_1 = tx_data_1.get_total_expense(None, &conn); - let total_expense_2 = tx_data_2.get_total_expense(None, &conn); - - // No tx available within the selected index so 0 - let expected_data_1: Vec = vec!["Expense", "0.00", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - let expected_data_2: Vec = vec!["Expense", "0.00", "100.00", "100.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - assert_eq!(total_expense_1, expected_data_1); - assert_eq!(total_expense_2, expected_data_2); - - tx_data_2.del_tx(0, &mut conn).unwrap(); - - let tx_data_2 = TransactionData::new(6, 1, &conn); - - assert!(!tx_data_2.is_tx_empty()); - assert_eq!(tx_data_2.get_txs().len(), 1); - - let txs = get_all_txs(&conn, 6, 1); - let tx_data = TransactionData::new_search(txs.0, txs.2); - - assert_eq!(tx_data.get_txs().len(), 1); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Another transaction", - "Super Special Bank", - "100.00", - "Expense", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Another transaction", - "Cash Cow", - "200.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - let tx_data = TransactionData::new(6, 1, &conn); - - let daily_expense = tx_data.get_daily_expense(Some(1), &conn); - let daily_income = tx_data.get_daily_income(Some(3), &conn); - - assert_eq!(daily_expense[0], "Daily Expense"); - assert_eq!(daily_expense[1], "100.00"); - assert_eq!(daily_expense[2], "100.00"); - assert_eq!(daily_expense[3], "200.00"); - - assert_eq!(daily_income[0], "Daily Income"); - assert_eq!(daily_income[1], "200.00"); - assert_eq!(daily_income[2], "200.00"); - assert_eq!(daily_income[3], "400.00"); - - let daily_expense = tx_data.get_daily_expense(None, &conn); - let daily_income = tx_data.get_daily_income(None, &conn); - - assert_eq!(daily_expense[0], "Daily Expense"); - assert_eq!(daily_expense[1], "0.00"); - assert_eq!(daily_expense[2], "0.00"); - assert_eq!(daily_expense[3], "0.00"); - - assert_eq!(daily_income[0], "Daily Income"); - assert_eq!(daily_income[1], "0.00"); - assert_eq!(daily_income[2], "0.00"); - assert_eq!(daily_income[3], "0.00"); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/lerp.rs b/tests_old/lerp.rs deleted file mode 100644 index 2578afe..0000000 --- a/tests_old/lerp.rs +++ /dev/null @@ -1,32 +0,0 @@ -extern crate rex_tui; -use rex_tui::utility::LerpState; -use std::thread::sleep; -use std::time::Duration; - -#[test] -fn lerp_test() { - let mut lerp_state = LerpState::new(1.0); - - lerp_state.lerp("test1", 10.0); - - sleep(Duration::from_millis(100)); - - let new_value = lerp_state.lerp("test1", 10.0); - - assert!(new_value < 10.0); - assert!(lerp_state.has_active_lerps()); - - sleep(Duration::from_millis(1000)); - - let new_value = lerp_state.lerp("test1", 10.0); - - assert!(new_value == 10.0); - assert!(!lerp_state.has_active_lerps()); - - lerp_state.lerp("test1", 100.0); - sleep(Duration::from_millis(100)); - - lerp_state.clear(); - - assert!(!lerp_state.has_active_lerps()); -} diff --git a/tests_old/stepper.rs b/tests_old/stepper.rs deleted file mode 100644 index d8544e1..0000000 --- a/tests_old/stepper.rs +++ /dev/null @@ -1,587 +0,0 @@ -extern crate rex_tui; -use rex_tui::db::create_db; -use rex_tui::outputs::{StepType, SteppingError}; -use rex_tui::page_handler::DateType; -use rex_tui::tx_handler::*; -use rex_tui::utility::traits::{DataVerifier, FieldStepper}; -use rusqlite::Connection; -use std::fs; - -struct Testing { - data: Vec, - expected: Vec, - result: Vec>, -} -impl FieldStepper for Testing {} -impl DataVerifier for Testing {} - -fn create_test_db(file_name: &str) -> Connection { - if let Ok(metadata) = fs::metadata(file_name) - && metadata.is_file() - { - fs::remove_file(file_name).expect("Failed to delete existing file"); - } - - let mut conn = Connection::open(file_name).unwrap(); - create_db( - &[ - "Super Special Bank".to_string(), - "Cash Cow".to_string(), - "Danger Cash".to_string(), - ], - &mut conn, - ) - .unwrap(); - conn -} - -fn add_dummy_tx(conn: &mut Connection) { - add_tx( - "2022-08-19", - "Car expense", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Food cost", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Selling goods", - "Super Special Bank", - "200.00", - "Income", - "Goods", - None, - conn, - ) - .unwrap(); -} - -#[test] -fn test_stepper_date() { - let data = vec![ - "", - "2020-05-01", - "2025-05-15", - "2025-13-01", - "2025-05-35", - "2040-05-01", - "2037-12-31", - "2022-01-01", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec![ - "2022-01-01", - "2022-05-01", - "2025-05-16", - "2025-12-01", - "2025-05-31", - "2037-05-01", - "2037-12-31", - "2022-01-02", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Err(SteppingError::InvalidDate), - Ok(()), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepUp, &DateType::Exact); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec![ - "2022-01-01", - "2022-05-01", - "2025-05-14", - "2025-12-01", - "2025-05-31", - "2037-05-01", - "2037-12-30", - "2022-01-01", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Err(SteppingError::InvalidDate), - Ok(()), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepDown, &DateType::Exact); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let data = vec!["", "2022-01", "2022-13", "2040-01", "2037-12"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec!["2022-01", "2022-02", "2022-12", "2037-01", "2037-12"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Ok(()), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepUp, &DateType::Monthly); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec!["2022-01", "2022-01", "2022-12", "2037-01", "2037-11"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Ok(()), - Err(SteppingError::InvalidDate), - Err(SteppingError::InvalidDate), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepDown, &DateType::Monthly); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let data = vec!["", "2022", "2037", "2040"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec!["2022", "2023", "2037", "2037"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![Ok(()), Ok(()), Ok(()), Err(SteppingError::InvalidDate)]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepUp, &DateType::Yearly); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec!["2022", "2022", "2036", "2037"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![Ok(()), Ok(()), Ok(()), Err(SteppingError::InvalidDate)]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_date(&mut to_verify, StepType::StepDown, &DateType::Yearly); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } -} - -#[test] -fn test_stepper_tx_method() { - let file_name = "stepper_tx_method.sqlite"; - let mut conn = create_test_db(file_name); - add_dummy_tx(&mut conn); - - let data = vec!["", "Super", "Super Special Bank", "Cash Cow", "Danger Cash"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec![ - "Super Special Bank", - "Super Special Bank", - "Cash Cow", - "Danger Cash", - "Super Special Bank", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Err(SteppingError::InvalidTxMethod), - Ok(()), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tx_method(&mut to_verify, StepType::StepUp, &conn); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec![ - "Super Special Bank", - "Super Special Bank", - "Danger Cash", - "Super Special Bank", - "Cash Cow", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Err(SteppingError::InvalidTxMethod), - Ok(()), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data, - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tx_method(&mut to_verify, StepType::StepDown, &conn); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn test_stepper_amount() { - let data = vec!["0", "99999999999.99", "123456", "-123456", ""] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec!["1.00", "9999999999.99", "123457.00", "123457.00", "1.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![Ok(()), Ok(()), Ok(()), Ok(()), Ok(())]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_amount(&mut to_verify, StepType::StepUp); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec!["0.00", "9999999998.99", "123455.00", "123455.00", "1.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![Ok(()), Ok(()), Ok(()), Ok(()), Ok(())]; - - let test_data = Testing { - data, - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_amount(&mut to_verify, StepType::StepDown); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } -} - -#[test] -fn test_stepper_tx_type() { - let data = vec![ - "", "e", "E", "t", "T", "i", "I", "v", "Expense", "Income", "Transfer", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected = vec![ - "Income", "Transfer", "Transfer", "Income", "Income", "Expense", "Expense", "", "Transfer", - "Expense", "Income", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Err(SteppingError::InvalidTxType), - Ok(()), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tx_type(&mut to_verify, StepType::StepUp); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec![ - "Income", "Income", "Income", "Expense", "Expense", "Transfer", "Transfer", "", "Income", - "Transfer", "Expense", - ] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let result = vec![ - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Err(SteppingError::InvalidTxType), - Ok(()), - Ok(()), - Ok(()), - ]; - - let test_data = Testing { - data, - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tx_type(&mut to_verify, StepType::StepDown); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } -} - -#[test] -fn test_stepper_tags() { - let file_name = "tag_stepper_test.sqlite"; - let mut conn = create_test_db(file_name); - - let data = vec!["Hmm", "", "123"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let expected = vec!["", "", ""] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let result = vec![ - Err(SteppingError::InvalidTags), - Err(SteppingError::InvalidTags), - Err(SteppingError::InvalidTags), - ]; - - let test_data = Testing { - data, - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tags(&mut to_verify, "", StepType::StepUp, &conn); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - add_dummy_tx(&mut conn); - - let data = vec!["", "car", "fOoD", "Goods", "Car,", "Car, Food", "Boom"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let expected = vec!["Car", "Food", "Goods", "Car", "Car, Car", "Car, Goods", ""] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let result = vec![ - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Err(SteppingError::InvalidTags), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tags(&mut to_verify, "", StepType::StepUp, &conn); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - let expected = vec!["Car", "Goods", "Car", "Food", "Car, Car", "Car, Car", ""] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - let result = vec![ - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Ok(()), - Err(SteppingError::InvalidTags), - ]; - - let test_data = Testing { - data: data.clone(), - expected, - result, - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.step_tags(&mut to_verify, "", StepType::StepDown, &conn); - - assert_eq!(to_verify, test_data.expected[i]); - assert_eq!(result, test_data.result[i]); - } - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/summary.rs b/tests_old/summary.rs deleted file mode 100644 index 83e8bd0..0000000 --- a/tests_old/summary.rs +++ /dev/null @@ -1,513 +0,0 @@ -extern crate rex_tui; -use rex_tui::page_handler::{IndexedData, SortingType}; -use rex_tui::summary_page::{ - LargestType, PeakType, SummaryData, SummaryLargest, SummaryMethods, SummaryNet, SummaryPeak, -}; -use rex_tui::tx_handler::add_tx; -use rex_tui::utility::sort_table_data; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_summary_data_1() { - let file_name = "summary_data_1.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Testing transaction", - "Super Special Bank", - "200.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - let summary_modes = IndexedData::new_modes(); - - let my_summary = SummaryData::new(&conn); - let (old_net, _, _, old_methods) = - my_summary.get_tx_data(&summary_modes, 5, 1, &None, &None, &conn); - - let my_summary_text = my_summary.get_table_data(&summary_modes, 6, 1); - let (net, largest, peak, methods) = my_summary.get_tx_data( - &summary_modes, - 6, - 1, - &Some(old_methods), - &Some(old_net), - &conn, - ); - - let expected_data_1 = vec![vec!["Food", "200.00", "100.00", "100.00", "100.00"]]; - - let expected_net = SummaryNet::new( - 200.0, - 100.0, - None, - None, - 66.66666666666666, - 33.33333333333333, - Some("∞".to_string()), - Some("∞".to_string()), - ); - let expected_largest_1 = SummaryLargest::new( - LargestType::Earning, - "Super Special Bank".to_string(), - 200.0, - "25-07-2023".to_string(), - ); - - let expected_largest_2 = SummaryLargest::new( - LargestType::Expense, - "Cash Cow".to_string(), - 100.0, - "19-07-2023".to_string(), - ); - - let expected_peak_1 = SummaryPeak::new(PeakType::Earning, 200.0, "07-2023".to_string()); - let expected_peak_2 = SummaryPeak::new(PeakType::Expense, 100.0, "07-2023".to_string()); - - let expected_methods = vec![ - SummaryMethods::new( - "Super Special Bank".to_string(), - 200.0, - 0.0, - 100.0, - 0.0, - None, - None, - Some("∞".to_string()), - Some("∞".to_string()), - ), - SummaryMethods::new( - "Cash Cow".to_string(), - 0.0, - 100.0, - 0.0, - 100.0, - None, - None, - Some("∞".to_string()), - Some("∞".to_string()), - ), - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(my_summary_text, expected_data_1); - assert_eq!(net, expected_net); - assert_eq!(peak, vec![expected_peak_1, expected_peak_2]); - assert_eq!(largest, vec![expected_largest_1, expected_largest_2]); - assert_eq!(methods, expected_methods); -} - -#[test] -fn check_summary_data_2() { - let file_name = "summary_data_2.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2023-08-19", - "Testing transaction", - "Super Special Bank", - "500.00", - "Expense", - "Car", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-01-19", - "Testing transaction", - "Super Special Bank", - "500.00", - "Expense", - "Car", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "700.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-05-19", - "Testing transaction", - "Super Special Bank", - "1000.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - let mut summary_modes = IndexedData::new_modes(); - summary_modes.next(); - - let my_summary = SummaryData::new(&conn); - let (old_net, _, _, old_methods) = - my_summary.get_tx_data(&summary_modes, 0, 0, &None, &None, &conn); - let my_summary_text = my_summary.get_table_data(&summary_modes, 0, 1); - let (net, largest, peak, methods) = my_summary.get_tx_data( - &summary_modes, - 0, - 1, - &Some(old_methods), - &Some(old_net), - &conn, - ); - - let expected_net = SummaryNet::new( - 700.0, - 1000.0, - Some(233.33333333333334), - Some(333.3333333333333), - 41.17647058823529, - 58.82352941176471, - Some("↓30.00".to_string()), - Some("∞".to_string()), - ); - let expected_largest_1 = SummaryLargest::new( - LargestType::Earning, - "Cash Cow".to_string(), - 700.0, - "19-07-2023".to_string(), - ); - - let expected_largest_2 = SummaryLargest::new( - LargestType::Expense, - "Super Special Bank".to_string(), - 500.0, - "19-01-2023".to_string(), - ); - - let expected_peak_1 = SummaryPeak::new(PeakType::Earning, 700.0, "07-2023".to_string()); - let expected_peak_2 = SummaryPeak::new(PeakType::Expense, 500.0, "01-2023".to_string()); - - let expected_methods = vec![ - SummaryMethods::new( - "Super Special Bank".to_string(), - 0.0, - 1000.0, - 0.0, - 100.0, - Some(0.0), - Some(333.3333333333333), - Some("↓100.00".to_string()), - Some("∞".to_string()), - ), - SummaryMethods::new( - "Cash Cow".to_string(), - 700.0, - 0.0, - 100.0, - 0.0, - Some(233.33333333333334), - Some(0.0), - Some("∞".to_string()), - Some("∞".to_string()), - ), - ]; - let expected_data_1 = vec![ - vec![ - "Car".to_string(), - "0.00".to_string(), - "1000.00".to_string(), - "0.00".to_string(), - "100.00".to_string(), - ], - vec![ - "Food".to_string(), - "700.00".to_string(), - "0.00".to_string(), - "100.00".to_string(), - "0.00".to_string(), - ], - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(my_summary_text, expected_data_1); - assert_eq!(net, expected_net); - assert_eq!(peak, vec![expected_peak_1, expected_peak_2]); - assert_eq!(largest, vec![expected_largest_1, expected_largest_2]); - assert_eq!(methods, expected_methods); -} - -#[test] -fn check_summary_data_3() { - let file_name = "summary_data_3.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2024-07-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - let mut summary_modes = IndexedData::new_modes(); - summary_modes.next(); - summary_modes.next(); - - let my_summary = SummaryData::new(&conn); - let my_summary_text = my_summary.get_table_data(&summary_modes, 0, 1); - let (net, largest, peak, methods) = - my_summary.get_tx_data(&summary_modes, 0, 1, &None, &None, &conn); - - let expected_net = SummaryNet::new( - 200.0, - 100.0, - Some(66.66666666666667), - Some(33.333333333333336), - 66.66666666666666, - 33.33333333333333, - None, - None, - ); - let expected_largest_1 = SummaryLargest::new( - LargestType::Earning, - "Cash Cow".to_string(), - 100.0, - "19-07-2023".to_string(), - ); - - let expected_largest_2 = SummaryLargest::new( - LargestType::Expense, - "Super Special Bank".to_string(), - 100.0, - "19-08-2022".to_string(), - ); - - let expected_peak_1 = SummaryPeak::new(PeakType::Earning, 100.0, "07-2023".to_string()); - let expected_peak_2 = SummaryPeak::new(PeakType::Expense, 100.0, "08-2022".to_string()); - - let expected_methods = vec![ - SummaryMethods::new( - "Super Special Bank".to_string(), - 100.0, - 100.0, - 50.0, - 100.0, - Some(33.333333333333336), - Some(33.333333333333336), - None, - None, - ), - SummaryMethods::new( - "Cash Cow".to_string(), - 100.0, - 0.0, - 50.00, - 0.0, - Some(33.333333333333336), - Some(0.0), - None, - None, - ), - ]; - let expected_data_1 = vec![ - vec![ - "Car".to_string(), - "0.00".to_string(), - "100.00".to_string(), - "0.00".to_string(), - "100.00".to_string(), - ], - vec![ - "Food".to_string(), - "200.00".to_string(), - "0.00".to_string(), - "100.00".to_string(), - "0.00".to_string(), - ], - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(my_summary_text, expected_data_1); - assert_eq!(net, expected_net); - assert_eq!(peak, vec![expected_peak_1, expected_peak_2]); - assert_eq!(largest, vec![expected_largest_1, expected_largest_2]); - assert_eq!(methods, expected_methods); -} - -#[test] -fn check_summary_sorting() { - let file_name = "summary_sorting.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "1000.00", - "Expense", - "Car", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "500.00", - "Income", - "Food", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2024-07-19", - "Testing transaction", - "Super Special Bank", - "2000.00", - "Income", - "Bank", - None, - &mut conn, - ) - .unwrap(); - - let mut summary_modes = IndexedData::new_modes(); - summary_modes.next(); - summary_modes.next(); - - let my_summary = SummaryData::new(&conn); - let table_data = my_summary.get_table_data(&summary_modes, 0, 0); - - let sorted_data_1 = sort_table_data(table_data.clone(), &SortingType::ByTags); - let sorted_data_2 = sort_table_data(table_data.clone(), &SortingType::ByIncome); - let sorted_data_3 = sort_table_data(table_data.clone(), &SortingType::ByExpense); - - let expected_data_1 = vec![ - ["Bank", "2000.00", "0.00", "80.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Car", "0.00", "1000.00", "0.00", "100.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Food", "500.00", "0.00", "20.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ]; - - let expected_data_2 = vec![ - ["Bank", "2000.00", "0.00", "80.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Food", "500.00", "0.00", "20.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Car", "0.00", "1000.00", "0.00", "100.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ]; - - let expected_data_3 = vec![ - ["Car", "0.00", "1000.00", "0.00", "100.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Bank", "2000.00", "0.00", "80.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ["Food", "500.00", "0.00", "20.00", "0.00"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(), - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(sorted_data_1, expected_data_1); - assert_eq!(sorted_data_2, expected_data_2); - assert_eq!(sorted_data_3, expected_data_3); -} diff --git a/tests_old/tx.rs b/tests_old/tx.rs deleted file mode 100644 index 305480b..0000000 --- a/tests_old/tx.rs +++ /dev/null @@ -1,281 +0,0 @@ -extern crate rex_tui; -use rex_tui::tx_handler::add_tx; -use rex_tui::tx_handler::delete_tx; -use rex_tui::utility::{get_all_tx_columns, get_all_txs, get_last_tx_id}; -use rusqlite::Result as sqlResult; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_last_tx_id_1() { - let file_name = "last_tx_id_1.sqlite"; - let conn = create_test_db(file_name); - - let data = get_last_tx_id(&conn); - let expected_data: sqlResult = Err(rusqlite::Error::QueryReturnedNoRows); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_last_tx_id_2() { - let file_name = "last_tx_id_2.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-09-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - let data = get_last_tx_id(&conn); - let expected_data: sqlResult = Ok(1); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_getting_all_tx_1() { - let file_name = "getting_tx_1.sqlite"; - let conn = create_test_db(file_name); - - let data = get_all_txs(&conn, 6, 0); - let expected_data = (Vec::new(), Vec::new(), Vec::new()); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); -} - -#[test] -fn check_getting_all_tx_2() { - let file_name = "getting_tx_2.sqlite"; - let mut conn = create_test_db(file_name); - - println!("Starting"); - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-05-15", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-05-20", - "Testing transaction", - "Cash Cow", - "100.00", - "Income", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-05-25", - "Testing transfer", - "Cash Cow to Super Special Bank", - "100.00", - "Transfer", - "Unknown", - None, - &mut conn, - ) - .unwrap(); - - println!("Done with 1"); - - let data = get_all_txs(&conn, 6, 0); - let data_2 = get_all_txs(&conn, 4, 0); - - let expected_data = ( - vec![ - vec![ - "19-07-2022".to_string(), - "Testing transaction".to_string(), - "Super Special Bank".to_string(), - "100.00".to_string(), - "Expense".to_string(), - "Unknown".to_string(), - ], - vec![ - "19-07-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Expense".to_string(), - "Unknown".to_string(), - ], - ], - vec![ - vec!["0.00".to_string(), "-100.00".to_string()], - vec!["0.00".to_string(), "-200.00".to_string()], - ], - vec!["1".to_string(), "2".to_string()], - ); - - let expected_data_2 = ( - vec![ - vec![ - "15-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Expense".to_string(), - "Unknown".to_string(), - ], - vec![ - "20-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Income".to_string(), - "Unknown".to_string(), - ], - vec![ - "25-05-2022".to_string(), - "Testing transfer".to_string(), - "Cash Cow to Super Special Bank".to_string(), - "100.00".to_string(), - "Transfer".to_string(), - "Unknown".to_string(), - ], - ], - vec![ - vec!["0.00".to_string(), "-100.00".to_string()], - vec!["0.00".to_string(), "0.00".to_string()], - vec!["100.00".to_string(), "-100.00".to_string()], - ], - vec!["3".to_string(), "4".to_string(), "5".to_string()], - ); - - delete_tx(5, &mut conn).unwrap(); - - add_tx( - "2022-05-25", - "Testing transfer", - "Cash Cow to Super Special Bank", - "500.00", - "Transfer", - "Unknown", - Some("5"), - &mut conn, - ) - .unwrap(); - - let data_3 = get_all_txs(&conn, 4, 0); - - let expected_data_3 = ( - vec![ - vec![ - "15-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Expense".to_string(), - "Unknown".to_string(), - ], - vec![ - "20-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Income".to_string(), - "Unknown".to_string(), - ], - vec![ - "25-05-2022".to_string(), - "Testing transfer".to_string(), - "Cash Cow to Super Special Bank".to_string(), - "500.00".to_string(), - "Transfer".to_string(), - "Unknown".to_string(), - ], - ], - vec![ - vec!["0.00".to_string(), "-100.00".to_string()], - vec!["0.00".to_string(), "0.00".to_string()], - vec!["500.00".to_string(), "-500.00".to_string()], - ], - vec!["3".to_string(), "4".to_string(), "5".to_string()], - ); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(data, expected_data); - println!("Completed 1"); - assert_eq!(data_2, expected_data_2); - println!("Completed 2"); - assert_eq!(data_3, expected_data_3); - println!("Completed 3"); -} - -#[test] -fn check_tx_columns() { - let file_name = "tx_columns.sqlite"; - let conn = create_test_db(file_name); - - let columns = get_all_tx_columns(&conn); - let expected_data = vec![ - "date".to_string(), - "details".to_string(), - "tx_method".to_string(), - "amount".to_string(), - "tx_type".to_string(), - "id_num".to_string(), - "tags".to_string(), - ]; - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(columns, expected_data); - assert_eq!(columns.len(), 7); -} diff --git a/tests_old/tx_data.rs b/tests_old/tx_data.rs deleted file mode 100644 index 497fb46..0000000 --- a/tests_old/tx_data.rs +++ /dev/null @@ -1,670 +0,0 @@ -extern crate rex_tui; -use chrono::prelude::Local; -use rex_tui::outputs::{AType, CheckingError, NAType, TxType, VerifyingOutput}; -use rex_tui::page_handler::{DateType, TxTab}; -use rex_tui::tx_handler::{TxData, add_tx}; -use rusqlite::Connection; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -fn add_dummy_tx(conn: &mut Connection) { - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Expense", - "Car", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Expense", - "Food", - None, - conn, - ) - .unwrap(); - - add_tx( - "2023-07-25", - "Testing transaction", - "Super Special Bank to Cash Cow", - "200.00", - "Transfer", - "Food", - None, - conn, - ) - .unwrap(); -} - -#[test] -fn test_tx_data_1() { - let mut tx_data = TxData::new(); - - let local_time = Local::now().to_string(); - let expected_data = vec![&local_time[0..10], "", "", "", "", "", "", ""]; - assert_eq!(tx_data.get_all_texts(), expected_data); - - tx_data.clear_date(); - - let expected_data = vec!["", "", "", "", "", "", "", ""]; - assert_eq!(tx_data.get_all_texts(), expected_data); - assert_eq!(tx_data.get_tx_status(), &Vec::::new()); - assert!(tx_data.check_all_empty()); - - tx_data.add_tx_status("Some status".to_string()); - - assert_eq!(tx_data.get_tx_status(), &vec!["Some status".to_string()]); - - let tx_data = TxData::custom( - "2024-06-15", - "details", - "Super Special Bank", - "Cash Cow", - "100", - "Transfer", - "tags", - 0, - ); - - assert_eq!(tx_data.get_tx_type(), TxType::Transfer); - assert_eq!( - tx_data.get_tx_method(), - "Super Special Bank to Cash Cow".to_string() - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "", - "100", - "Expense", - "tags", - 0, - ); - - assert_eq!(tx_data.get_tx_type(), TxType::IncomeExpense); - assert_eq!(tx_data.get_tx_method(), "Super Special Bank".to_string()); - assert!(tx_data.check_all_fields().is_none()); - assert!(!tx_data.check_all_empty()); - - let current_index = tx_data.get_current_index(); - - tx_data.move_index_right(&TxTab::Date); - tx_data.move_index_right(&TxTab::Date); - - assert_eq!(tx_data.get_current_index(), current_index + 2); - - tx_data.move_index_left(&TxTab::Date); - - assert_eq!(tx_data.get_current_index(), current_index + 1); - - tx_data.move_index_left(&TxTab::Date); - tx_data.move_index_left(&TxTab::Date); - tx_data.move_index_left(&TxTab::Date); - tx_data.move_index_left(&TxTab::Date); - - assert_eq!(tx_data.get_current_index(), current_index); - - tx_data.go_current_index(&TxTab::Date); - - assert_eq!(tx_data.get_current_index(), 10); - - let mut tx_data = TxData::custom( - "", - "details", - "Super Special Bank", - "", - "100", - "Expense", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::EmptyDate - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "Super Special Bank", - "100", - "Transfer", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::SameTxMethod - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "", - "Super Special Bank", - "100", - "Expense", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::EmptyMethod - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "Super Special Bank", - "", - "Expense", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::EmptyAmount - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "Super Special Bank", - "100", - "", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::EmptyTxType - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "", - "100", - "Transfer", - "tags", - 0, - ); - assert_eq!( - tx_data.check_all_fields().unwrap(), - CheckingError::EmptyMethod - ); - - let mut tx_data = TxData::custom( - "2023-07-19", - "details", - "Super Special Bank", - "Cash Cow", - "100", - "Transfer", - "", - 0, - ); - assert!(tx_data.check_all_fields().is_none()); -} - -#[test] -fn test_tx_data_verifier() { - let file_name = "tx_data_verifier.sqlite"; - let conn = create_test_db(file_name); - - let mut tx_data = TxData::custom( - "15-06-2023", - "details", - "Super Special Bank", - "Nope", - "b+100", - "Transfer", - "tags, asdf", - 0, - ); - - let date_status = tx_data.check_date(&DateType::Exact); - let from_method_verifier = tx_data.check_from_method(&conn); - let to_method_verifier = tx_data.check_to_method(&conn); - let tx_type_status = tx_data.check_tx_type(); - let tags_status = tx_data.check_tags_forced(&conn); - let amount_status = tx_data.check_amount(false, &conn); - - assert_eq!(date_status, VerifyingOutput::Accepted(AType::Date)); - assert_eq!( - from_method_verifier, - VerifyingOutput::Accepted(AType::TxMethod) - ); - assert_eq!( - to_method_verifier, - VerifyingOutput::NotAccepted(NAType::InvalidTxMethod) - ); - assert_eq!(tx_type_status, VerifyingOutput::Accepted(AType::TxType)); - assert_eq!( - tags_status, - VerifyingOutput::NotAccepted(NAType::NonExistingTag) - ); - assert_eq!(amount_status, VerifyingOutput::Accepted(AType::Amount)); - - let mut tx_data = TxData::custom( - "15-06-2023", - "details", - "Super Special Bank", - "Nope", - "b+100", - "Transfer", - "tags, tags", - 0, - ); - - tx_data.check_tags(); - - assert_eq!(tx_data.get_all_texts()[6], "tags"); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn test_tx_data_stepper() { - let file_name = "tx_data_stepper.sqlite"; - let conn = create_test_db(file_name); - - let mut tx_data = TxData::custom( - "15-06-2023", - "details", - "Super Special Bank", - "Nope", - "b+100", - "Transfer", - "tags, asdf", - 0, - ); - - let date_step_up = tx_data.do_date_up(&DateType::Exact); - let date_step_down = tx_data.do_date_down(&DateType::Exact); - - let amount_step_up = tx_data.do_amount_up(false, &conn); - let amount_step_down = tx_data.do_amount_down(false, &conn); - - let tx_method_up = tx_data.do_from_method_up(&conn); - let tx_method_down = tx_data.do_from_method_down(&conn); - - let tx_to_up = tx_data.do_to_method_up(&conn); - let tx_to_down = tx_data.do_to_method_down(&conn); - - let tx_type_up = tx_data.do_tx_type_up(); - let tx_type_down = tx_data.do_tx_type_down(); - - let tags_up = tx_data.do_tags_up(&conn); - let tags_down = tx_data.do_tags_down(&conn); - - assert!(date_step_up.is_ok()); - assert!(date_step_down.is_ok()); - assert!(amount_step_up.is_ok()); - assert!(amount_step_down.is_ok()); - assert!(tx_method_up.is_ok()); - assert!(tx_method_down.is_ok()); - assert!(tx_to_up.is_err()); - assert!(tx_to_down.is_ok()); - assert!(tx_type_up.is_ok()); - assert!(tx_type_down.is_ok()); - assert!(tags_up.is_err()); - assert!(tags_down.is_ok()); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn tx_data_searching() { - let file_name = "tx_data_searching_test.sqlite"; - let mut conn = create_test_db(file_name); - let tx_data = TxData::new_empty(); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data, (Vec::new(), Vec::new())); - - add_dummy_tx(&mut conn); - - assert!(tx_data.check_all_empty()); - - let tx_data = TxData::custom("19-07-2023", "", "", "", "", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - let tx_data = TxData::custom("19-07-2023", "", "", "", "", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Monthly, &conn); - assert_eq!(data.0.len(), 2); - - let mut tx_data = TxData::new_empty(); - - for i in ['2', '0', '2', '3'] { - tx_data.edit_date(Some(i)); - } - - let data = tx_data.get_search_tx(&DateType::Yearly, &conn); - assert_eq!(data.0.len(), 2); - - let tx_data = TxData::custom("", "Testing transaction", "", "", "", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 3); - - let tx_data = TxData::custom("", "", "Super Special Bank", "", "", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - let tx_data = TxData::custom( - "", - "", - "Super Special Bank", - "Cash Cow", - "", - "Transfer", - "", - 0, - ); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - let tx_data = TxData::custom("", "", "", "", "100.00", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 2); - - let tx_data = TxData::custom("", "", "", "", ">100.00", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - let tx_data = TxData::custom("", "", "", "", "<200.00", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 2); - - let tx_data = TxData::custom("", "", "", "", ">=100.00", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 3); - - let tx_data = TxData::custom("", "", "", "", "<=100.00", "", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 2); - - let tx_data = TxData::custom("", "", "", "", "", "Transfer", "", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - let tx_data = TxData::custom("", "", "", "", "", "", "Food, Car", 0); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 3); - - let tx_data = TxData::custom( - "19-07-2023", - "Testing transaction", - "Cash Cow", - "", - "100.00", - "Expense", - "Food", - 0, - ); - - let data = tx_data.get_search_tx(&DateType::Exact, &conn); - assert_eq!(data.0.len(), 1); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn tx_data_editing() { - let mut tx_data = TxData::new_empty(); - - for i in ['2', '0', '2', '3', '-', '0', '7', '-', '0', '5'] { - tx_data.edit_date(Some(i)); - } - - tx_data.go_current_index(&TxTab::Details); - - for i in ['S', 'o', 'm', 'e'] { - tx_data.edit_details(Some(i)); - } - - tx_data.go_current_index(&TxTab::FromMethod); - - for i in [ - 'S', 'u', 'p', 'e', 'r', ' ', 'S', 'p', 'e', 'c', 'i', 'a', 'l', ' ', 'B', 'a', 'n', 'k', - ] { - tx_data.edit_from_method(Some(i)); - } - - tx_data.go_current_index(&TxTab::Amount); - - for i in ['2', '0', '2', '3'] { - tx_data.edit_amount(Some(i)); - } - - tx_data.go_current_index(&TxTab::TxType); - - let i = 'E'; - tx_data.edit_tx_type(Some(i)); - - tx_data.go_current_index(&TxTab::ToMethod); - - for i in ['C', 'a', 's', 'h', ' ', 'C', 'o', 'w'] { - tx_data.edit_to_method(Some(i)); - } - - tx_data.go_current_index(&TxTab::Tags); - - for i in ['T', 'a', 'g'] { - tx_data.edit_tags(Some(i)); - } - - let expected_data: Vec = vec![ - "2023-07-05", - "Some", - "Super Special Bank", - "Cash Cow", - "2023", - "E", - "Tag", - "", - ] - .into_iter() - .map(ToString::to_string) - .collect(); - - assert_eq!(tx_data.get_all_texts(), expected_data); - - tx_data.go_current_index(&TxTab::Date); - - for _ in ['2', '0', '2', '3', '-', '0', '7', '-', '0', '5'] { - tx_data.edit_date(None); - } - - tx_data.go_current_index(&TxTab::Details); - - for _ in ['S', 'o', 'm', 'e'] { - tx_data.edit_details(None); - } - - tx_data.go_current_index(&TxTab::FromMethod); - - for _ in [ - 'S', 'u', 'p', 'e', 'r', ' ', 'S', 'p', 'e', 'c', 'i', 'a', 'l', ' ', 'B', 'a', 'n', 'k', - ] { - tx_data.edit_from_method(None); - } - - tx_data.go_current_index(&TxTab::Amount); - - for _ in ['2', '0', '2', '3'] { - tx_data.edit_amount(None); - } - - tx_data.go_current_index(&TxTab::TxType); - - let _ = 'E'; - tx_data.edit_tx_type(None); - - tx_data.go_current_index(&TxTab::ToMethod); - - for _ in ['C', 'a', 's', 'h', ' ', 'C', 'o', 'w'] { - tx_data.edit_to_method(None); - } - - tx_data.go_current_index(&TxTab::Tags); - - for _ in ['T', 'a', 'g'] { - tx_data.edit_tags(None); - } - - let expected_data: Vec = vec!["", "", "", "", "", "", "", ""] - .into_iter() - .map(ToString::to_string) - .collect(); - - assert_eq!(tx_data.get_all_texts(), expected_data); -} - -#[test] -fn tx_data_suffix() { - let file_name = "tx_data_suffix.sqlite"; - let conn = create_test_db(file_name); - - let mut tx_data = TxData::new_empty(); - - tx_data.amount = String::from("1k"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("1000.00")); - - tx_data.amount = String::from("1m"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("1000000.00")); - - tx_data.amount = String::from("1km"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("1000000000.00")); - - tx_data.amount = String::from("1k1"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("11.00")); - - tx_data.amount = String::from("5m12"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("512.00")); - - tx_data.amount = String::from("100 + 5k"); - tx_data.check_amount(false, &conn); - - assert_eq!(tx_data.amount, String::from("5100.00")); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn tx_data_generation() { - let file_name = "tx_data_generation.sqlite"; - let conn = create_test_db(file_name); - - let mut tx_data = TxData::new_empty(); - - let balance_data: Vec = vec!["Balance", "0.00", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - let change_data: Vec = vec!["Changes", "0.00", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - let given = tx_data.generate_balance_section(&conn, balance_data.clone(), change_data.clone()); - let given_changes = tx_data.generate_changes_section(&conn); - - let expected = vec!["Balance", "0", "0", "0"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected_changes = vec!["Changes", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - assert_eq!(given, expected); - assert_eq!(given_changes, expected_changes); - - let balance_data: Vec = vec!["Balance", "0.00", "0.00", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect(); - - tx_data.amount = "100.00".to_string(); - tx_data.tx_type = "Expense".to_string(); - tx_data.from_method = "Super Special Bank".to_string(); - - let given = tx_data.generate_balance_section(&conn, balance_data.clone(), change_data); - let given_changes = tx_data.generate_changes_section(&conn); - - let expected = vec!["Balance", "-100", "0", "-100"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - let expected_changes = vec!["Changes", "↓100", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - assert_eq!(given, expected); - assert_eq!(given_changes, expected_changes); - - tx_data.tx_type = "Income".to_string(); - - let given_changes = tx_data.generate_changes_section(&conn); - - let expected_changes = vec!["Changes", "↑100", "0.00"] - .into_iter() - .map(std::string::ToString::to_string) - .collect::>(); - - assert_eq!(given_changes, expected_changes); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/tx_method.rs b/tests_old/tx_method.rs deleted file mode 100644 index 38a39e2..0000000 --- a/tests_old/tx_method.rs +++ /dev/null @@ -1,50 +0,0 @@ -extern crate rex_tui; -use rex_tui::db::*; -use rex_tui::utility::get_all_tx_methods; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_getting_tx_methods_1() { - let file_name = "getting_tx_methods_1.sqlite"; - let conn = create_test_db(file_name); - let data = get_all_tx_methods(&conn); - conn.close().unwrap(); - - fs::remove_file(file_name).unwrap(); - - assert_eq!( - data, - vec!["Super Special Bank".to_string(), "Cash Cow".to_string()] - ); -} - -#[test] -fn check_getting_tx_methods_2() { - let file_name = "getting_tx_methods_2.sqlite"; - let mut conn = create_test_db(file_name); - - add_new_tx_methods( - &["new method 1".to_string(), "testing methods".to_string()], - &mut conn, - ) - .unwrap(); - - let data = get_all_tx_methods(&conn); - conn.close().unwrap(); - - fs::remove_file(file_name).unwrap(); - - assert_eq!( - data, - vec![ - "Super Special Bank".to_string(), - "Cash Cow".to_string(), - "new method 1".to_string(), - "testing methods".to_string() - ] - ); -} diff --git a/tests_old/ui_states.rs b/tests_old/ui_states.rs deleted file mode 100644 index 245779c..0000000 --- a/tests_old/ui_states.rs +++ /dev/null @@ -1,85 +0,0 @@ -extern crate rex_tui; -use chrono::{Datelike, Local}; -use rex_tui::db::{MODES, MONTHS, YEARS}; -use rex_tui::page_handler::*; - -#[test] -fn test_table_data() { - let table_data = vec![ - vec![ - "15-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Expense".to_string(), - "Unknown".to_string(), - ], - vec![ - "20-05-2022".to_string(), - "Testing transaction".to_string(), - "Cash Cow".to_string(), - "100.00".to_string(), - "Income".to_string(), - "Unknown".to_string(), - ], - vec![ - "25-05-2022".to_string(), - "Testing transfer".to_string(), - "Cash Cow to Super Special Bank".to_string(), - "100.00".to_string(), - "Transfer".to_string(), - "Unknown".to_string(), - ], - ]; - let mut table = TableData::new(table_data); - assert_eq!(table.state.selected(), None); - - table.next(); - assert_eq!(table.state.selected(), Some(0)); - - table.state.select(None); - table.previous(); - assert_eq!(table.state.selected(), Some(0)); - - table.state.select(Some(0)); - table.next(); - table.next(); - assert_eq!(table.state.selected(), Some(2)); - table.next(); - table.next(); - assert_eq!(table.state.selected(), Some(1)); - table.previous(); - table.previous(); - assert_eq!(table.state.selected(), Some(2)); -} - -#[test] -fn test_indexed_data() { - let local_month_index = Local::now().month() as usize - 1; - let local_year_index = Local::now().year() as usize - 2022; - - let mut index_data_monthly = IndexedData::new_monthly(); - let mut index_data_yearly = IndexedData::new_yearly(); - let index_data_modes = IndexedData::new_modes(); - - assert_eq!(index_data_monthly.titles, MONTHS); - assert_eq!(index_data_yearly.titles, YEARS); - assert_eq!(index_data_modes.titles, MODES); - - assert_eq!(index_data_monthly.index, local_month_index); - assert_eq!(index_data_yearly.index, local_year_index); - assert_eq!(index_data_modes.index, 0); - - index_data_yearly.set_index_zero(); - index_data_monthly.set_index_zero(); - assert_eq!(index_data_yearly.index, 0); - assert_eq!(index_data_monthly.index, 0); - - index_data_monthly.next(); - index_data_monthly.next(); - assert_eq!(index_data_monthly.index, 2); - - index_data_yearly.previous(); - index_data_yearly.previous(); - assert_eq!(index_data_yearly.index, YEARS.len() - 2); -} diff --git a/tests_old/utils.rs b/tests_old/utils.rs deleted file mode 100644 index 1506016..0000000 --- a/tests_old/utils.rs +++ /dev/null @@ -1,154 +0,0 @@ -extern crate rex_tui; - -use rex_tui::tx_handler::add_tx; -use rex_tui::utility::*; -use std::env::current_dir; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -#[test] -fn check_unique_tags() { - let file_name = "tag_checker.sqlite"; - let mut conn = create_test_db(file_name); - - add_tx( - "2022-07-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "Test tag", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-07-19", - "Testing transaction", - "Cash Cow", - "100.00", - "Income", - "Tag name", - None, - &mut conn, - ) - .unwrap(); - - add_tx( - "2022-08-19", - "Testing transaction", - "Super Special Bank", - "100.00", - "Income", - "test tag", - None, - &mut conn, - ) - .unwrap(); - - let all_tags = get_all_tags(&conn); - let expected_data = ["Tag name", "Test tag", "test tag"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); - - assert_eq!(all_tags, expected_data); -} - -#[test] -fn check_restricted_test() { - let word_list = ["Unknown", "Words", "Testing"] - .iter() - .map(|s| (*s).to_string()) - .collect::>(); - - let is_restricted = check_restricted("cancel", None); - let not_restricted = check_restricted("some word", None); - - assert!(is_restricted); - assert!(!not_restricted); - - let is_restricted = check_restricted("unknown", Some(&word_list)); - let not_restricted = check_restricted("some word", Some(&word_list)); - - assert!(is_restricted); - assert!(!not_restricted); -} - -#[test] -fn github_parser_test() { - let body = "## Updates -* Some release -* text that are taken -* from the latest github release - -## Changes -more stuff" - .to_string(); - - let parsed = parse_github_body(&body); - - let expected_data = " -• Some release -• text that are taken -• from the latest github release -" - .to_string(); - - assert_eq!(parsed, expected_data); -} - -#[test] -fn test_location_json() { - let mut current_dir = current_dir().unwrap(); - let json_exists = is_location_changed(¤t_dir); - assert_eq!(json_exists, None); - - create_change_location_file(¤t_dir, ¤t_dir); - - let json_exists = is_location_changed(¤t_dir); - assert_eq!(json_exists, Some(current_dir.clone())); - - current_dir.pop(); - current_dir.push("location.json"); - fs::remove_file(current_dir).unwrap(); -} - -#[test] -fn misc_tests() { - let file_name = "misc_check.sqlite"; - let conn = create_test_db(file_name); - - let mut all_tx_methods = get_all_tx_methods(&conn); - let all_tx_methods_cumulative = get_all_tx_methods_cumulative(&conn); - - all_tx_methods.push("Cumulative".to_string()); - - assert_eq!(all_tx_methods, all_tx_methods_cumulative); - - let table_names = get_all_table_names(&conn); - - let expected_tables = [ - "tx_all", - "sqlite_sequence", - "balance_all", - "changes_all", - "activities", - "activity_txs", - ] - .iter() - .map(|s| (*s).to_string()) - .collect::>(); - - assert_eq!(table_names, expected_tables); - - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} diff --git a/tests_old/verifier.rs b/tests_old/verifier.rs deleted file mode 100644 index 181fe73..0000000 --- a/tests_old/verifier.rs +++ /dev/null @@ -1,262 +0,0 @@ -extern crate rex_tui; -use rex_tui::outputs::{AType, NAType, VerifyingOutput}; -use rex_tui::page_handler::DateType; -use rex_tui::utility::traits::DataVerifier; -use rex_tui::utility::*; -use std::fs; - -mod common; - -use crate::common::create_test_db; - -struct Testing { - data: Vec, - expected: Vec, - result: Vec, -} -impl DataVerifier for Testing {} - -#[test] -fn check_sql_dates() { - let data = get_sql_dates(11, 2, &DateType::Monthly); - let expected_data = ("2024-12-01".to_string(), "2024-12-31".to_string()); - assert_eq!(data, expected_data); -} - -#[test] -fn check_verifier_date() { - let test_data = Testing { - data: vec![ - String::new(), - "2022-01-01".to_string(), - " 2022 - 01 - 01 ".to_string(), - "2022-01".to_string(), - "2022-01-0".to_string(), - "2022-0-01".to_string(), - "01-01-2022".to_string(), - "2022-01-32".to_string(), - "2022-02-31".to_string(), - "2022-13-31".to_string(), - "2038-01-31".to_string(), - "2022-01-".to_string(), - "20222-01-01".to_string(), - "2022-015-01".to_string(), - "2022-01-311".to_string(), - ], - expected: vec![ - String::new(), - "2022-01-01".to_string(), - "2022-01-01".to_string(), - "2022-01-01".to_string(), - "2022-01-00".to_string(), - "2022-00-01".to_string(), - "2022-01-2022".to_string(), - "2022-01-31".to_string(), - "2022-02-31".to_string(), - "2022-12-31".to_string(), - "2037-01-31".to_string(), - "2022-01-".to_string(), - "2022-01-01".to_string(), - "2022-12-01".to_string(), - "2022-01-31".to_string(), - ], - result: vec![ - VerifyingOutput::Nothing(AType::Date), - VerifyingOutput::Accepted(AType::Date), - VerifyingOutput::Accepted(AType::Date), - VerifyingOutput::NotAccepted(NAType::InvalidDate), - VerifyingOutput::NotAccepted(NAType::InvalidDay), - VerifyingOutput::NotAccepted(NAType::InvalidMonth), - VerifyingOutput::NotAccepted(NAType::InvalidYear), - VerifyingOutput::NotAccepted(NAType::DayTooBig), - VerifyingOutput::NotAccepted(NAType::NonExistingDate), - VerifyingOutput::NotAccepted(NAType::MonthTooBig), - VerifyingOutput::NotAccepted(NAType::YearTooBig), - VerifyingOutput::NotAccepted(NAType::ParsingError(AType::Date)), - VerifyingOutput::NotAccepted(NAType::InvalidYear), - VerifyingOutput::NotAccepted(NAType::InvalidMonth), - VerifyingOutput::NotAccepted(NAType::InvalidDay), - ], - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.verify_date(&mut to_verify, &DateType::Exact); - assert_eq!(result, test_data.result[i]); - assert_eq!(to_verify, test_data.expected[i]); - } -} - -#[test] -fn check_verifier_amount() { - let test_data = Testing { - data: vec![ - String::new(), - "1".to_string(), - "1.".to_string(), - "1.0".to_string(), - " -100 ".to_string(), - "100+".to_string(), - "-100 * ".to_string(), - "100-50".to_string(), - "50 - 100".to_string(), - "100 + 50".to_string(), - "100*2".to_string(), - "100/2".to_string(), - " 2/7 ".to_string(), - " 1000000000000000.52 ".to_string(), - "@%15612".to_string(), - " 5 + 2 * 3 - 5".to_string(), - "1.0000".to_string(), - ], - expected: vec![ - String::new(), - "1.00".to_string(), - "1.00".to_string(), - "1.00".to_string(), - "100.00".to_string(), - "100.00".to_string(), - "100.00".to_string(), - "50.00".to_string(), - "50.00".to_string(), - "150.00".to_string(), - "200.00".to_string(), - "50.00".to_string(), - "0.29".to_string(), - "1000000000.52".to_string(), - "15612.00".to_string(), - "6.00".to_string(), - "1.00".to_string(), - ], - - result: vec![ - VerifyingOutput::Nothing(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::NotAccepted(NAType::AmountBelowZero), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - VerifyingOutput::Accepted(AType::Amount), - ], - }; - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.verify_amount(&mut to_verify); - assert_eq!(result, test_data.result[i]); - assert_eq!(to_verify, test_data.expected[i]); - } -} - -#[test] -fn check_verifier_tx_method() { - let test_data = Testing { - data: vec![ - String::new(), - "Cash Cow".to_string(), - "random".to_string(), - " Cash Cow ".to_string(), - "te".to_string(), - ], - expected: vec![ - String::new(), - "Cash Cow".to_string(), - "Cash Cow".to_string(), - "Cash Cow".to_string(), - "Super Special Bank".to_string(), - ], - result: vec![ - VerifyingOutput::Nothing(AType::TxMethod), - VerifyingOutput::Accepted(AType::TxMethod), - VerifyingOutput::NotAccepted(NAType::InvalidTxMethod), - VerifyingOutput::Accepted(AType::TxMethod), - VerifyingOutput::NotAccepted(NAType::InvalidTxMethod), - ], - }; - let file_name = "check_verifier_tx_method.sqlite"; - let conn = create_test_db(file_name); - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.verify_tx_method(&mut to_verify, &conn); - assert_eq!(result, test_data.result[i]); - assert_eq!(to_verify, test_data.expected[i]); - } - conn.close().unwrap(); - fs::remove_file(file_name).unwrap(); -} - -#[test] -fn check_verifier_tx_type() { - let test_data = Testing { - data: vec![ - String::new(), - "e".to_string(), - "i".to_string(), - "w".to_string(), - " i".to_string(), - " i ".to_string(), - ], - expected: vec![ - String::new(), - "Expense".to_string(), - "Income".to_string(), - String::new(), - "Income".to_string(), - "Income".to_string(), - ], - result: vec![ - VerifyingOutput::Nothing(AType::TxType), - VerifyingOutput::Accepted(AType::TxType), - VerifyingOutput::Accepted(AType::TxType), - VerifyingOutput::NotAccepted(NAType::InvalidTxType), - VerifyingOutput::Accepted(AType::TxType), - VerifyingOutput::Accepted(AType::TxType), - ], - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - let result = test_data.verify_tx_type(&mut to_verify); - assert_eq!(result, test_data.result[i]); - assert_eq!(to_verify, test_data.expected[i]); - } -} - -#[test] -fn check_verifier_tags() { - let test_data = Testing { - data: vec![ - String::new(), - "tag1,".to_string(), - "tag1, , , , ".to_string(), - "tag1,tag2,tag3".to_string(), - "tag1,tag1,tag1".to_string(), - "tag1, Tag1, tAg1".to_string(), - ], - expected: vec![ - String::new(), - "tag1".to_string(), - "tag1".to_string(), - "tag1, tag2, tag3".to_string(), - "tag1".to_string(), - "tag1, Tag1, tAg1".to_string(), - ], - result: Vec::new(), - }; - - for i in 0..test_data.data.len() { - let mut to_verify = test_data.data[i].clone(); - test_data.verify_tags(&mut to_verify); - assert_eq!(to_verify, test_data.expected[i]); - } -} diff --git a/tui/Cargo.toml b/tui/Cargo.toml index 3075cad..37bdf28 100644 --- a/tui/Cargo.toml +++ b/tui/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/TheRustyPickle/Rex" license = "MIT" keywords = ["tui", "terminal", "budget", "ratatui", "money"] categories = ["command-line-utilities"] -exclude = ["logo.png", "tests_old", ".github", "typos.toml", "codecov.yml"] +exclude = ["logo.png", ".github", "typos.toml", "codecov.yml"] [[bin]] name = "rex"