test refactoring
Some checks failed
Rust Build / Check (pull_request) Successful in 39s
Rust Build / Test Suite (pull_request) Failing after 43s
Rust Build / Rustfmt (pull_request) Failing after 22s
Rust Build / Clippy (pull_request) Successful in 37s
Rust Build / build (pull_request) Successful in 1m2s

This commit is contained in:
2025-05-31 21:42:49 -04:00
parent 8baac56f7c
commit f016c7903f

View File

@@ -69,12 +69,9 @@ mod tests {
mod db_mgr {
use std::str::FromStr;
use icarus_auth::keys;
pub const LIMIT: usize = 6;
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
dotenvy::dotenv().ok(); // Load .env file if it exists
let tm_db_url = icarus_envy::environment::get_db_url().await;
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
sqlx::PgPool::connect_with(tm_options).await
@@ -114,10 +111,11 @@ mod tests {
}
pub fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
dotenvy::dotenv().ok(); // Load .env file if it exists
let rt = tokio::runtime::Runtime::new().unwrap();
// Block on the async function to get the result
let database_url = rt.block_on(icarus_envy::environment::get_db_url());
match std::env::var(icarus_envy::keys::DB_URL) {
Ok(database_url) => {
let parsed_url = url::Url::parse(&database_url)?;
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
match parsed_url
@@ -132,12 +130,6 @@ mod tests {
Err("Error parsing".into())
}
}
Err(_) => {
// DATABASE_URL environment variable not found
Err("Error parsing".into())
}
}
}
}
fn get_test_register_request() -> icarus_auth::callers::register::request::Request {