Making it simpler
All checks were successful
Rust Build / Check (pull_request) Successful in 1m14s
Rust Build / Test Suite (pull_request) Successful in 1m1s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m13s
All checks were successful
Rust Build / Check (pull_request) Successful in 1m14s
Rust Build / Test Suite (pull_request) Successful in 1m1s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m13s
This commit is contained in:
@@ -93,8 +93,7 @@ mod tests {
|
||||
}
|
||||
|
||||
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
||||
let db_url = std::env::var("TEST_DATABASE_URL")
|
||||
.expect("TEST_DATABASE_URL must be set for tests");
|
||||
let db_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set for tests");
|
||||
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
||||
sqlx::PgPool::connect_with(options).await
|
||||
}
|
||||
@@ -123,7 +122,7 @@ mod tests {
|
||||
pub fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
||||
dotenvy::dotenv().ok(); // Load .env file if it exists
|
||||
|
||||
match std::env::var("TEST_DATABASE_URL") {
|
||||
match std::env::var("DATABASE_URL") {
|
||||
Ok(database_url) => {
|
||||
let parsed_url = url::Url::parse(&database_url)?;
|
||||
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
||||
@@ -140,7 +139,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
// TEST_DATABASE_URL environment variable not found
|
||||
// DATABASE_URL environment variable not found
|
||||
Err("Error parsing".into())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user