refactor(config): require explicit BZOD data directory
This commit is contained in:
1 parent
d398341f01
commit
c2e138f823
55 files changed
+522
-170
No files matched your search
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -19,10 +19,9 @@ use bzod::web::admin::{
|
||||
};
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -21,8 +21,7 @@ use bzod::db::Db;
|
||||
use bzod::web::admin::{dashboard_get, login_post, LoginForm};
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
+1
-2
@@ -7,8 +7,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -7,8 +7,7 @@ use tar::Archive;
|
||||
use zstd::Decoder;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
@@ -200,8 +199,7 @@ async fn test_restore_slug_collision_rejection() {
|
||||
));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
fs::create_dir_all(&config.backup_dir).unwrap();
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -6,8 +6,7 @@ use std::sync::Arc;
|
||||
use tokio::sync::Barrier;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
use bzod::config::{Config, ConfigError, NX9_BZOD_DATA_DIR_ENV};
|
||||
use bzod::db::topology::Topology;
|
||||
use bzod::identity::TenantId;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
|
||||
// Global lock to prevent race conditions during env-var testing
|
||||
static ENV_LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
struct EnvGuard {
|
||||
key: &'static str,
|
||||
original_val: Option<String>,
|
||||
}
|
||||
|
||||
impl EnvGuard {
|
||||
fn set(key: &'static str, val: &str) -> Self {
|
||||
let original_val = env::var(key).ok();
|
||||
env::set_var(key, val);
|
||||
Self { key, original_val }
|
||||
}
|
||||
|
||||
fn unset(key: &'static str) -> Self {
|
||||
let original_val = env::var(key).ok();
|
||||
env::remove_var(key);
|
||||
Self { key, original_val }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for EnvGuard {
|
||||
fn drop(&mut self) {
|
||||
if let Some(ref val) = self.original_val {
|
||||
env::set_var(self.key, val);
|
||||
} else {
|
||||
env::remove_var(self.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_configuration_returns_missing_data_dir_error() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let _guard = EnvGuard::unset(NX9_BZOD_DATA_DIR_ENV);
|
||||
|
||||
// Call load_from_sources with no CLI and load_dotenv=false in an isolated context
|
||||
let res = Config::load_from_sources(None::<&Path>, false);
|
||||
|
||||
assert!(
|
||||
res.is_err(),
|
||||
"Expected error when no data directory is configured"
|
||||
);
|
||||
match res.err().unwrap() {
|
||||
ConfigError::MissingDataDir => {}
|
||||
other => panic!("Expected ConfigError::MissingDataDir, got {:?}", other),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_environment_variable_resolves_data_dir() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let test_path = "/tmp/nx9-env-test-data";
|
||||
let _guard = EnvGuard::set(NX9_BZOD_DATA_DIR_ENV, test_path);
|
||||
|
||||
let config = Config::load_from_sources(None::<&Path>, false)
|
||||
.expect("Config should load with NX9_BZOD_DATA_DIR set");
|
||||
|
||||
assert_eq!(config.data_dir, PathBuf::from(test_path));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_config_file_resolves_data_dir() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let _guard = EnvGuard::unset(NX9_BZOD_DATA_DIR_ENV);
|
||||
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_cfg_test_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
|
||||
let toml_file = temp_dir.join("bzod.toml");
|
||||
let target_data_dir = "/tmp/config-file-data";
|
||||
fs::write(&toml_file, format!("data_dir = \"{}\"\n", target_data_dir)).unwrap();
|
||||
|
||||
// Change current directory temporarily for config file reading
|
||||
let original_cwd = env::current_dir().unwrap();
|
||||
env::set_current_dir(&temp_dir).unwrap();
|
||||
|
||||
let config_res = Config::load_from_sources(None::<&Path>, false);
|
||||
|
||||
// Restore cwd
|
||||
env::set_current_dir(original_cwd).unwrap();
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
|
||||
let config = config_res.expect("Config should load from bzod.toml");
|
||||
assert_eq!(config.data_dir, PathBuf::from(target_data_dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_environment_overrides_config_file() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let env_data_dir = "/tmp/env-override-data";
|
||||
let _guard = EnvGuard::set(NX9_BZOD_DATA_DIR_ENV, env_data_dir);
|
||||
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_cfg_test_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
|
||||
let toml_file = temp_dir.join("bzod.toml");
|
||||
let config_data_dir = "/tmp/config-file-data";
|
||||
fs::write(&toml_file, format!("data_dir = \"{}\"\n", config_data_dir)).unwrap();
|
||||
|
||||
let original_cwd = env::current_dir().unwrap();
|
||||
env::set_current_dir(&temp_dir).unwrap();
|
||||
|
||||
let config_res = Config::load_from_sources(None::<&Path>, false);
|
||||
|
||||
env::set_current_dir(original_cwd).unwrap();
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
|
||||
let config = config_res.expect("Config should load");
|
||||
assert_eq!(config.data_dir, PathBuf::from(env_data_dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cli_overrides_environment() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let env_data_dir = "/tmp/env-data";
|
||||
let _guard = EnvGuard::set(NX9_BZOD_DATA_DIR_ENV, env_data_dir);
|
||||
|
||||
let cli_data_dir = "/tmp/cli-override-data";
|
||||
let config = Config::load_from_sources(Some(cli_data_dir), false)
|
||||
.expect("Config should load with CLI override");
|
||||
|
||||
assert_eq!(config.data_dir, PathBuf::from(cli_data_dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cli_overrides_config_file() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let _guard = EnvGuard::unset(NX9_BZOD_DATA_DIR_ENV);
|
||||
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_cfg_test_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
|
||||
let toml_file = temp_dir.join("bzod.toml");
|
||||
let config_data_dir = "/tmp/config-file-data";
|
||||
fs::write(&toml_file, format!("data_dir = \"{}\"\n", config_data_dir)).unwrap();
|
||||
|
||||
let original_cwd = env::current_dir().unwrap();
|
||||
env::set_current_dir(&temp_dir).unwrap();
|
||||
|
||||
let cli_data_dir = "/tmp/cli-data-highest";
|
||||
let config_res = Config::load_from_sources(Some(cli_data_dir), false);
|
||||
|
||||
env::set_current_dir(original_cwd).unwrap();
|
||||
let _ = fs::remove_dir_all(&temp_dir);
|
||||
|
||||
let config = config_res.expect("Config should load with CLI override");
|
||||
assert_eq!(config.data_dir, PathBuf::from(cli_data_dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_relative_path_semantics_preserved() {
|
||||
let _lock = ENV_LOCK.lock().unwrap();
|
||||
let relative_path = "custom_relative/data";
|
||||
let config = Config::load_from_sources(Some(relative_path), false)
|
||||
.expect("Relative path in CLI should be accepted as-is without forced canonicalization");
|
||||
|
||||
assert_eq!(config.data_dir, PathBuf::from(relative_path));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_topology_resolves_all_databases_relative_to_configured_root() {
|
||||
let custom_root = PathBuf::from("/var/lib/bzod/custom_root");
|
||||
let topology = Topology::new(&custom_root);
|
||||
|
||||
assert_eq!(topology.root(), &custom_root);
|
||||
assert_eq!(topology.admin_dir(), custom_root.join("admin"));
|
||||
assert_eq!(topology.slugs_dir(), custom_root.join("slugs"));
|
||||
assert_eq!(topology.users_dir(), custom_root.join("users"));
|
||||
|
||||
// Core databases
|
||||
assert_eq!(topology.admin_db(), custom_root.join("admin/admin.db"));
|
||||
assert_eq!(topology.system_db(), custom_root.join("admin/system.db"));
|
||||
assert_eq!(
|
||||
topology.users_registry_db(),
|
||||
custom_root.join("admin/users.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.global_urls_db(),
|
||||
custom_root.join("slugs/global_urls.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.global_landing_pages_db(),
|
||||
custom_root.join("slugs/global_landing_pages.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.reserved_db(),
|
||||
custom_root.join("slugs/reserved.db")
|
||||
);
|
||||
|
||||
// Tenant databases
|
||||
let tenant_id = TenantId::parse("a1b2c3d4e5f6").unwrap();
|
||||
assert_eq!(
|
||||
topology.tenant_dir(tenant_id),
|
||||
custom_root.join("users/a1b2c3d4e5f6")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.tenant_content_db(tenant_id),
|
||||
custom_root.join("users/a1b2c3d4e5f6/content.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.tenant_analytics_db(tenant_id),
|
||||
custom_root.join("users/a1b2c3d4e5f6/analytics.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.tenant_profile_db(tenant_id),
|
||||
custom_root.join("users/a1b2c3d4e5f6/profile.db")
|
||||
);
|
||||
assert_eq!(
|
||||
topology.extension_db("a1b2c3d4e5f6", "cv").unwrap(),
|
||||
custom_root.join("users/a1b2c3d4e5f6/extensions/cv/cv.db")
|
||||
);
|
||||
}
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -18,8 +18,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -5,8 +5,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -21,8 +21,7 @@ use std::path::PathBuf;
|
||||
use tar::Builder;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -6,8 +6,7 @@ use std::path::PathBuf;
|
||||
use uuid::Uuid;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -34,8 +34,7 @@ fn test_custom_slug_validation() {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -18,8 +18,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -18,8 +18,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -29,8 +29,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -5,8 +5,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -11,8 +11,7 @@ use std::path::PathBuf;
|
||||
use std::time::Instant;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -6,8 +6,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -5,8 +5,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -19,8 +19,7 @@ fn compute_sha256(value: &str) -> String {
|
||||
}
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.admin_username = "admin".to_string();
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
@@ -50,8 +50,7 @@ impl TestHarness {
|
||||
let temp_dir =
|
||||
std::env::temp_dir().join(format!("bzod_admin_boundary_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ use bzod::state::AppState;
|
||||
use bzod::web::create_router;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
config
|
||||
|
||||
@@ -55,8 +55,7 @@ impl TestHarness {
|
||||
let temp_dir =
|
||||
std::env::temp_dir().join(format!("bzod_user_boundary_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ use std::path::PathBuf;
|
||||
fn temp_config() -> (PathBuf, Config) {
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_v08_topology_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
(temp_dir, config)
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ fn temp_config() -> (PathBuf, Config) {
|
||||
let temp_dir =
|
||||
std::env::temp_dir().join(format!("bzod_v08_id_migrate_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
(temp_dir, config)
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ use uuid::Uuid;
|
||||
fn create_test_config() -> (PathBuf, Config) {
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_p6a_test_{}", Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
config.base_url = Some("http://localhost:8080".to_string());
|
||||
(temp_dir, config)
|
||||
|
||||
@@ -25,8 +25,7 @@ fn temp_config() -> (PathBuf, Config) {
|
||||
let temp_dir =
|
||||
std::env::temp_dir().join(format!("bzod_v08_slug_migrate_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
(temp_dir, config)
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ use std::time::Instant;
|
||||
fn temp_config() -> (PathBuf, Config) {
|
||||
let temp_dir = std::env::temp_dir().join(format!("bzod_v08_boundary_{}", uuid::Uuid::new_v4()));
|
||||
fs::create_dir_all(&temp_dir).unwrap();
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.join("backups");
|
||||
(temp_dir, config)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn create_temp_config(temp_dir: PathBuf) -> Config {
|
||||
let mut config = Config::load();
|
||||
config.data_dir = temp_dir.clone();
|
||||
let mut config = Config::load_with_cli(Some(&temp_dir)).unwrap();
|
||||
config.backup_dir = temp_dir.clone();
|
||||
config.base_url = Some("http://bzo.in".to_string());
|
||||
config
|
||||
|
||||
Reference in new issue
Block a user