diff --git a/Cargo.lock b/Cargo.lock index 07e8a94c1..d620bd265 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,6 +400,7 @@ dependencies = [ "rstest", "rusqlite", "rustyline", + "tempfile", ] [[package]] diff --git a/test/Cargo.toml b/test/Cargo.toml index 7c05dae4b..0638db64b 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -20,6 +20,7 @@ env_logger = "0.10.1" limbo_core = { path = "../core" } rustyline = "12.0.0" rusqlite = "0.29.0" +tempfile = "3.0.7" [dev-dependencies] rstest = "0.18.2" diff --git a/test/src/lib.rs b/test/src/lib.rs index 46ad3e879..6bdc12cb5 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -1,8 +1,7 @@ use limbo_core::Database; -use std::env; -use std::fs; use std::path::PathBuf; use std::sync::Arc; +use tempfile::TempDir; #[allow(dead_code)] struct TempDatabase { @@ -13,12 +12,9 @@ struct TempDatabase { #[allow(dead_code, clippy::arc_with_non_send_sync)] impl TempDatabase { pub fn new(table_sql: &str) -> Self { - let mut path = env::current_dir().unwrap(); + let mut path = TempDir::new().unwrap().into_path(); path.push("test.db"); { - if path.exists() { - fs::remove_file(&path).unwrap(); - } let connection = rusqlite::Connection::open(&path).unwrap(); connection.execute(table_sql, ()).unwrap(); } @@ -47,7 +43,7 @@ mod tests { let conn = tmp_db.connect_limbo(); let list_query = "SELECT * FROM test"; - let max_iterations = 10000; + let max_iterations = 1000; for i in 0..max_iterations { if (i % 100) == 0 { let progress = (i as f64 / max_iterations as f64) * 100.0;