[utils] Added print_calendar_list
This commit is contained in:
parent
f06b5ac9ae
commit
6ff4822d6e
2 changed files with 16 additions and 13 deletions
14
src/utils.rs
14
src/utils.rs
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
|
|
||||||
|
use crate::Calendar;
|
||||||
|
|
||||||
/// Walks an XML tree and returns every element that has the given name
|
/// Walks an XML tree and returns every element that has the given name
|
||||||
pub fn find_elems<S: AsRef<str>>(root: &Element, searched_name: S) -> Vec<&Element> {
|
pub fn find_elems<S: AsRef<str>>(root: &Element, searched_name: S) -> Vec<&Element> {
|
||||||
let searched_name = searched_name.as_ref();
|
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 _ = element.to_writer(&mut xml_writer);
|
||||||
let _ = writer.write(&[0x0a]);
|
let _ = writer.write(&[0x0a]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A debug utility that pretty-prints calendars
|
||||||
|
pub fn print_calendar_list(cals: &Vec<Calendar>) {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,25 +21,14 @@ async fn test_sync() {
|
||||||
|
|
||||||
let cals_server = provider.server().get_calendars().await.unwrap();
|
let cals_server = provider.server().get_calendars().await.unwrap();
|
||||||
let cals_local = provider.local().get_calendars().await.unwrap();
|
let cals_local = provider.local().get_calendars().await.unwrap();
|
||||||
print_calendar_list(cals_local);
|
my_tasks::utils::print_calendar_list(cals_local);
|
||||||
print_calendar_list(cals_server);
|
my_tasks::utils::print_calendar_list(cals_server);
|
||||||
panic!();
|
panic!();
|
||||||
|
|
||||||
//assert_eq!(cal_server, cal_local, "{:#?}\n{:#?}", cal_server, cal_local);
|
//assert_eq!(cal_server, cal_local, "{:#?}\n{:#?}", cal_server, cal_local);
|
||||||
|
|
||||||
panic!("TODO: also check that the contents are expected!");
|
panic!("TODO: also check that the contents are expected!");
|
||||||
}
|
|
||||||
|
|
||||||
/// A debug utility that pretty-prints calendars
|
|
||||||
fn print_calendar_list(cals: &Vec<Calendar>) {
|
|
||||||
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:
|
/// Populate sources with the following:
|
||||||
|
|
Loading…
Add table
Reference in a new issue