Default to value of `CARGO_MANIFEST_DIR` for SERVER_ROOT in test-setup
@@ -12,6 +12,7 @@ pub mod runtime;
/// The built-in connectors database.
pub mod connectors;
+use once_cell::sync::Lazy;
use quaint::{prelude::Queryable, single::Quaint};
use url::Url;
@@ -20,8 +21,11 @@ type AnyError = Box<dyn std::error::Error + Send + Sync>;
const SCHEMA_NAME: &str = "prisma-tests";
/// DANGER. This will be used for destructive filesystem access, be careful when changing this. DANGER.
-pub fn server_root() -> String {
- std::env::var("SERVER_ROOT").expect("Env var SERVER_ROOT required but not found.")
+pub fn server_root() -> &'static str {
+ static SERVER_ROOT: Lazy<String> =
+ Lazy::new(|| std::env::var("SERVER_ROOT").unwrap_or(env!("CARGO_MANIFEST_DIR").to_string()));
+
+ SERVER_ROOT.as_ref()
}
pub fn sqlite_test_url(db_name: &str) -> String {
