use std::time::Duration;
#[derive(Debug, Clone)]
pub struct TestConfig {
pub headless: bool,
pub timeout: Duration,
}
impl Default for TestConfig {
fn default() -> Self {
Self {
headless: true,
timeout: Duration::from_secs(30),
}
}
}
impl TestConfig {
pub fn new() -> Self {
Self::default()
}
pub fn builder() -> TestConfigBuilder {
TestConfigBuilder::default()
}
}
#[derive(Debug, Default)]
pub struct TestConfigBuilder {
headless: Option<bool>,
timeout: Option<Duration>,
}
impl TestConfigBuilder {
#[must_use]
pub fn headless(mut self, headless: bool) -> Self {
self.headless = Some(headless);
self
}
#[must_use]
pub fn timeout(mut self, timeout: Duration) -> Self {
self.timeout = Some(timeout);
self
}
pub fn build(self) -> TestConfig {
TestConfig {
headless: self.headless.unwrap_or(true),
timeout: self.timeout.unwrap_or(Duration::from_secs(30)),
}
}
}