use std::{collections::HashMap, time::Duration};
#[derive(Debug, Clone)]
pub struct TestEnvConfig {
pub name: String,
pub enable_logging: bool,
pub enable_tracing: bool,
pub default_timeout: Duration,
pub custom: HashMap<String, String>,
}
impl Default for TestEnvConfig {
fn default() -> Self {
Self {
name: "test".to_string(),
enable_logging: true,
enable_tracing: false,
default_timeout: Duration::from_secs(30),
custom: HashMap::new(),
}
}
}
impl TestEnvConfig {
pub fn new() -> Self {
Self::default()
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = name.into();
self
}
pub fn with_logging(mut self, enable: bool) -> Self {
self.enable_logging = enable;
self
}
pub fn with_tracing(mut self, enable: bool) -> Self {
self.enable_tracing = enable;
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.default_timeout = timeout;
self
}
pub fn custom(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
self.custom.insert(key.into(), value.into());
self
}
}
#[derive(Debug, Clone)]
pub struct TestServiceConfig {
pub name: String,
pub enabled: bool,
pub startup_timeout: Duration,
pub config: HashMap<String, String>,
}
impl TestServiceConfig {
pub fn new(name: impl Into<String>) -> Self {
Self { name: name.into(), enabled: true, startup_timeout: Duration::from_secs(30), config: HashMap::new() }
}
pub fn enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
pub fn startup_timeout(mut self, timeout: Duration) -> Self {
self.startup_timeout = timeout;
self
}
pub fn config(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
self.config.insert(key.into(), value.into());
self
}
}