mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 04:24:21 +01:00
Rewrite test to use temp dir
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -400,6 +400,7 @@ dependencies = [
|
||||
"rstest",
|
||||
"rusqlite",
|
||||
"rustyline",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user