friendly_errors/
summary.rs1use crate::FriendlyError;
2
3impl FriendlyError {
4 pub fn print_summary(&mut self) {
5 if let Some(url) = &self.data.summary {
6 let url = url.clone();
7 self.add_empty_line();
8 self.output.push_str(&url);
9 }
10 }
11}
12
13#[cfg(test)]
14mod test {
15 use super::*;
16 use indoc::indoc;
17
18 #[test]
19 fn test_append_summary() {
20 let mut error = FriendlyError::new().summary("I am the summary");
21 error.print_summary();
22 assert_eq!(error.output, "I am the summary");
23 }
24
25 #[test]
26 fn test_append_summary_with_output() {
27 let mut error = FriendlyError::new()
28 .summary("I am the summary")
29 .set_output("Error message");
30 error.print_summary();
31 assert_eq!(
32 error.output,
33 indoc!(
34 "
35 Error message
36
37 I am the summary"
38 )
39 );
40 }
41}