viewpoint_test/config/
mod.rs1use std::time::Duration;
4
5#[derive(Debug, Clone)]
7pub struct TestConfig {
8 pub headless: bool,
10 pub timeout: Duration,
12}
13
14impl Default for TestConfig {
15 fn default() -> Self {
16 Self {
17 headless: true,
18 timeout: Duration::from_secs(30),
19 }
20 }
21}
22
23impl TestConfig {
24 pub fn new() -> Self {
26 Self::default()
27 }
28
29 pub fn builder() -> TestConfigBuilder {
31 TestConfigBuilder::default()
32 }
33}
34
35#[derive(Debug, Default)]
37pub struct TestConfigBuilder {
38 headless: Option<bool>,
39 timeout: Option<Duration>,
40}
41
42impl TestConfigBuilder {
43 #[must_use]
45 pub fn headless(mut self, headless: bool) -> Self {
46 self.headless = Some(headless);
47 self
48 }
49
50 #[must_use]
52 pub fn timeout(mut self, timeout: Duration) -> Self {
53 self.timeout = Some(timeout);
54 self
55 }
56
57 pub fn build(self) -> TestConfig {
59 TestConfig {
60 headless: self.headless.unwrap_or(true),
61 timeout: self.timeout.unwrap_or(Duration::from_secs(30)),
62 }
63 }
64}