Refactor SQL test file to derive database type from app state instead of environment variable for improved consistency and clarity.

This commit is contained in:
lovasoa
2025-09-26 11:48:14 +02:00
committed by Ophir LOJKINE
parent 94519752fd
commit 112ef55b11
+3 -12
View File
@@ -81,18 +81,9 @@ async fn run_sql_test(
let test_file_path = test_file.to_string_lossy().replace('\\', "/");
let stem = test_file.file_stem().unwrap().to_str().unwrap();
let db_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite::memory:".to_string());
let db_type = if db_url.starts_with("postgres") {
"postgres"
} else if db_url.starts_with("mysql") || db_url.starts_with("mariadb") {
"mysql"
} else if db_url.starts_with("mssql") {
"mssql"
} else if db_url.starts_with("sqlite") {
"sqlite"
} else {
panic!("Unknown database type in DATABASE_URL: {db_url}");
};
let app_state = app_data.get_ref();
let db = &app_state.db;
let db_type = format!("{:?}", db.info.database_type).to_lowercase();
if stem.contains(&format!("_no{db_type}")) {
return Ok(TestResult::Skipped(format!(