diff --git a/.gitignore b/.gitignore index 558044ad..74509beb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ Cargo.lock *.sublime* .vscode .idea/* -*/.idea/* \ No newline at end of file +*/.idea/* +.env.local \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f5aaecd6..8e182151 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,7 @@ time = { version = "0.3", features = ["macros"] } uuid = { version = "1", features = ["v4"] } once_cell = "1.8" arraystring = "0.3" +dotenv = "0.15" [features] debug-print = [] diff --git a/tests/basic.rs b/tests/basic.rs index 8c466ea6..54a9f47c 100644 --- a/tests/basic.rs +++ b/tests/basic.rs @@ -8,6 +8,9 @@ pub use sea_orm::{entity::*, error::*, query::*, sea_query, tests_cfg::*, Databa #[sea_orm_macros::test] #[cfg(feature = "sqlx-sqlite")] async fn main() -> Result<(), DbErr> { + dotenv::from_filename(".env.local").ok(); + dotenv::from_filename(".env").ok(); + let base_url = std::env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite::memory:".to_owned()); let db: DbConn = Database::connect(&base_url).await?; diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 68d986b6..359bc9db 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -13,6 +13,9 @@ pub struct TestContext { impl TestContext { pub async fn new(test_name: &str) -> Self { + dotenv::from_filename(".env.local").ok(); + dotenv::from_filename(".env").ok(); + let base_url = std::env::var("DATABASE_URL").expect("Enviroment variable 'DATABASE_URL' not set"); let db: DatabaseConnection = setup::setup(&base_url, test_name).await;