wae_testing/environment/
config.rs1use std::{collections::HashMap, time::Duration};
4
5#[derive(Debug, Clone)]
7pub struct TestEnvConfig {
8 pub name: String,
10 pub enable_logging: bool,
12 pub enable_tracing: bool,
14 pub default_timeout: Duration,
16 pub custom: HashMap<String, String>,
18}
19
20impl Default for TestEnvConfig {
21 fn default() -> Self {
22 Self {
23 name: "test".to_string(),
24 enable_logging: true,
25 enable_tracing: false,
26 default_timeout: Duration::from_secs(30),
27 custom: HashMap::new(),
28 }
29 }
30}
31
32impl TestEnvConfig {
33 pub fn new() -> Self {
35 Self::default()
36 }
37
38 pub fn name(mut self, name: impl Into<String>) -> Self {
40 self.name = name.into();
41 self
42 }
43
44 pub fn with_logging(mut self, enable: bool) -> Self {
46 self.enable_logging = enable;
47 self
48 }
49
50 pub fn with_tracing(mut self, enable: bool) -> Self {
52 self.enable_tracing = enable;
53 self
54 }
55
56 pub fn timeout(mut self, timeout: Duration) -> Self {
58 self.default_timeout = timeout;
59 self
60 }
61
62 pub fn custom(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
64 self.custom.insert(key.into(), value.into());
65 self
66 }
67}
68
69#[derive(Debug, Clone)]
73pub struct TestServiceConfig {
74 pub name: String,
76 pub enabled: bool,
78 pub startup_timeout: Duration,
80 pub config: HashMap<String, String>,
82}
83
84impl TestServiceConfig {
85 pub fn new(name: impl Into<String>) -> Self {
87 Self { name: name.into(), enabled: true, startup_timeout: Duration::from_secs(30), config: HashMap::new() }
88 }
89
90 pub fn enabled(mut self, enabled: bool) -> Self {
92 self.enabled = enabled;
93 self
94 }
95
96 pub fn startup_timeout(mut self, timeout: Duration) -> Self {
98 self.startup_timeout = timeout;
99 self
100 }
101
102 pub fn config(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
104 self.config.insert(key.into(), value.into());
105 self
106 }
107}