1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::domain::{{ snake }}::model::{{ pascal }};
use crate::domain::{{ snake }}::model::{{ pascal }}Props;{{ imports }}
pub struct {{ pascal }}Mother {
{{ fields_str }}
}
impl {{ pascal }}Mother {
pub fn new() -> Self {
Self { {{ defaults }} }
}
{{ with_methods_str }}{{ empty_methods_str }}
pub fn build(self) -> {{ pascal }} {
{{ pascal }}::new({{ pascal }}Props {
{{ build_assignments_str }}
})
.expect("{{ pascal }}Mother: failed to build valid {{ pascal }}")
}
pub fn build_props(self) -> {{ pascal }}Props {
{{ pascal }}Props {
{{ props_assignments_str }}
}
}
pub fn random() -> {{ pascal }} {
Self::new().build()
}
pub fn random_vec(n: usize) -> Vec<{{ pascal }}> {
(0..n).map(|_| Self::random()).collect()
}
}
impl Default for {{ pascal }}Mother {
fn default() -> Self {
Self::new()
}
}