klirr_core/models/
valid_input.rs1use crate::prelude::*;
2
3#[derive(Debug, Clone, Display, Builder, Getters)]
8#[display("Layout: {}, Period: {}, out: {:?}, items: {}, language: {}", layout, period, maybe_output_path.as_ref().map(|d|d.display()), items, language)]
9pub struct ValidInput {
10 #[builder(default)]
13 #[getset(get = "pub")]
14 language: Language,
15
16 #[getset(get = "pub")]
25 period: YearMonthAndFortnight,
26
27 #[builder(default)]
29 #[getset(get = "pub")]
30 items: InvoicedItems,
31
32 #[builder(default)]
34 #[getset(get = "pub")]
35 layout: Layout,
36
37 #[getset(get = "pub")]
39 maybe_output_path: Option<PathBuf>,
40
41 #[getset(get = "pub")]
45 email: Option<DecryptedEmailSettings>,
46}
47
48impl HasSample for ValidInput {
49 fn sample() -> Self {
50 Self::builder()
51 .period(YearMonthAndFortnight::sample())
52 .items(InvoicedItems::sample())
53 .maybe_output_path(PathBuf::from("invoice.pdf"))
54 .build()
55 }
56
57 fn sample_other() -> Self {
58 Self::builder()
59 .period(YearMonthAndFortnight::sample_other())
60 .items(InvoicedItems::sample_other())
61 .build()
62 }
63}
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68 use test_log::test;
69
70 type Sut = ValidInput;
71
72 #[test]
73 fn valid_input_sample() {
74 let sample = Sut::sample();
75 assert!(sample.maybe_output_path.is_some());
76 }
77
78 #[test]
79 fn valid_input_sample_other() {
80 let sample = Sut::sample_other();
81 assert!(sample.maybe_output_path.is_none());
82 }
83}