From 6b8eedc79cc7059439a02766ad28fc93f4794ebf Mon Sep 17 00:00:00 2001 From: Benjamin Demetz <50681275+Benji377@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:42:41 +0100 Subject: [PATCH] Update db_ops_test.rs --- src-tauri/src/tests/db_ops_test.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src-tauri/src/tests/db_ops_test.rs b/src-tauri/src/tests/db_ops_test.rs index b672263e..584499ae 100644 --- a/src-tauri/src/tests/db_ops_test.rs +++ b/src-tauri/src/tests/db_ops_test.rs @@ -108,6 +108,31 @@ mod tests { assert!(db_ops.get_db_files().is_some()); } + #[test] + fn test_update_db_timeout() { + // Run the update_db function for 10 seconds, then kill it if no errors occurred before + let mut db_ops = DBOps::new(DB_FILE_LOC, None).unwrap(); + let _ = std::thread::spawn(move || { + let result = db_ops.update_db(); + if let Err(err) = result { + error!("Error occurred: {}", err); + assert!(false); + } + }); + std::thread::sleep(std::time::Duration::from_secs(10)); + + // If we got here, it means that the update_db function ran for 10 seconds without errors + // So we can safely assume that the function works as expected + assert!(true); + } + + #[test] + fn test_db_diff_func() { + let db_ops = DBOps::new(DB_FILE_LOC, None).unwrap(); + let diff = db_ops.get_diff_file(); + assert!(!diff.is_empty()); + } + #[cfg(test)] #[ctor::dtor] fn teardown() {