Fixed issue
This commit is contained in:
@@ -34,8 +34,8 @@ pub mod db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_db_url() -> String {
|
async fn get_db_url() -> String {
|
||||||
#[cfg(debug_assertions)] // Example: Only load .env in debug builds
|
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
|
// dotenvy::from_filename(".env").ok();
|
||||||
env::var(keys::DBURL).expect(keys::error::ERROR)
|
env::var(keys::DBURL).expect(keys::error::ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -74,6 +74,7 @@ mod tests {
|
|||||||
pub const LIMIT: usize = 6;
|
pub const LIMIT: usize = 6;
|
||||||
|
|
||||||
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
||||||
|
dotenvy::dotenv().ok(); // Load .env file if it exists
|
||||||
let tm_db_url = std::env::var(keys::DBURL).expect("DATABASE_URL must be present");
|
let tm_db_url = std::env::var(keys::DBURL).expect("DATABASE_URL must be present");
|
||||||
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
||||||
sqlx::PgPool::connect_with(tm_options).await
|
sqlx::PgPool::connect_with(tm_options).await
|
||||||
|
Reference in New Issue
Block a user