From 6ff4822d6e50437c29543281d7625a846e00e275 Mon Sep 17 00:00:00 2001 From: daladim Date: Sun, 28 Feb 2021 23:10:40 +0100 Subject: [PATCH] [utils] Added print_calendar_list --- src/utils.rs | 14 ++++++++++++++ tests/sync.rs | 15 ++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index b0e0a1b..d46b600 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,6 +2,8 @@ use minidom::Element; +use crate::Calendar; + /// Walks an XML tree and returns every element that has the given name pub fn find_elems>(root: &Element, searched_name: S) -> Vec<&Element> { let searched_name = searched_name.as_ref(); @@ -49,3 +51,15 @@ pub fn print_xml(element: &Element) { let _ = element.to_writer(&mut xml_writer); let _ = writer.write(&[0x0a]); } + +/// A debug utility that pretty-prints calendars +pub fn print_calendar_list(cals: &Vec) { + for cal in cals { + println!("CAL {}", cal.url()); + for (_, item) in cal.get_items() { + let task = item.unwrap_task(); + let completion = if task.completed() {"✓"} else {" "}; + println!(" {} {}", completion, task.name()); + } + } +} diff --git a/tests/sync.rs b/tests/sync.rs index d1d3da2..6886bf4 100644 --- a/tests/sync.rs +++ b/tests/sync.rs @@ -21,25 +21,14 @@ async fn test_sync() { let cals_server = provider.server().get_calendars().await.unwrap(); let cals_local = provider.local().get_calendars().await.unwrap(); - print_calendar_list(cals_local); - print_calendar_list(cals_server); + my_tasks::utils::print_calendar_list(cals_local); + my_tasks::utils::print_calendar_list(cals_server); panic!(); //assert_eq!(cal_server, cal_local, "{:#?}\n{:#?}", cal_server, cal_local); panic!("TODO: also check that the contents are expected!"); -} -/// A debug utility that pretty-prints calendars -fn print_calendar_list(cals: &Vec) { - for cal in cals { - println!("CAL {}", cal.url()); - for (_, item) in cal.get_items() { - let task = item.unwrap_task(); - let completion = if task.completed() {"✓"} else {" "}; - println!(" {} {}", completion, task.name()); - } - } } /// Populate sources with the following: