[minor] Tests

This commit is contained in:
daladim 2021-03-31 08:40:21 +02:00
parent 401099ed33
commit 931d74f577
2 changed files with 22 additions and 16 deletions

View file

@ -7,8 +7,6 @@ use minidom::Element;
use url::Url; use url::Url;
use my_tasks::client::Client; use my_tasks::client::Client;
use my_tasks::traits::BaseCalendar;
use my_tasks::traits::DavCalendar;
use my_tasks::traits::CalDavSource; use my_tasks::traits::CalDavSource;
use my_tasks::settings::URL; use my_tasks::settings::URL;
@ -16,6 +14,9 @@ use my_tasks::settings::USERNAME;
use my_tasks::settings::PASSWORD; use my_tasks::settings::PASSWORD;
use my_tasks::settings::EXAMPLE_TASK_URL; use my_tasks::settings::EXAMPLE_TASK_URL;
use my_tasks::settings::EXAMPLE_CALENDAR_URL; use my_tasks::settings::EXAMPLE_CALENDAR_URL;
use my_tasks::ItemId;
use my_tasks::traits::DavCalendar;
static EXAMPLE_TASKS_BODY_LAST_MODIFIED: &str = r#" static EXAMPLE_TASKS_BODY_LAST_MODIFIED: &str = r#"
<C:calendar-query xmlns:D="DAV:" <C:calendar-query xmlns:D="DAV:"
@ -45,19 +46,8 @@ async fn show_calendars() {
let calendars = client.get_calendars().await.unwrap(); let calendars = client.get_calendars().await.unwrap();
println!("Calendars:"); println!("Calendars:");
for (id, calendar) in calendars.iter() { my_tasks::utils::print_dav_calendar_list(&calendars).await;
let cal = calendar.lock().unwrap();
println!(" {}\t{}", cal.name(), id.as_str());
println!(" IDs:");
for id in cal.get_item_ids().await.unwrap() {
println!(" * {}", id);
}
println!(" Most recent changes:");
// for (_id, task) in cal.get_item_version_tags(None, None).await.unwrap() {
// my_tasks::utils::print_task(task);
// }
}
} }
#[tokio::test] #[tokio::test]
@ -104,3 +94,12 @@ async fn last_modified() {
let el: Element = res.text().await.unwrap().parse().unwrap(); let el: Element = res.text().await.unwrap().parse().unwrap();
my_tasks::utils::print_xml(&el); my_tasks::utils::print_xml(&el);
} }
//
//
// TODO: test w/ wrong creds
// TODO: test withou connection
//

View file

@ -24,14 +24,21 @@ async fn test_regular_sync() {
let _ = env_logger::builder().is_test(true).try_init(); let _ = env_logger::builder().is_test(true).try_init();
let mut provider = populate_test_provider().await; let mut provider = populate_test_provider().await;
let cals_server = provider.remote().get_calendars().await.unwrap();
println!("----Server, before sync-------");
my_tasks::utils::print_calendar_list(&cals_server).await;
let cals_local = provider.local().get_calendars().await.unwrap();
println!("\n----Local, before sync-------");
my_tasks::utils::print_calendar_list(&cals_local).await;
provider.sync().await.unwrap(); provider.sync().await.unwrap();
let cals_server = provider.remote().get_calendars().await.unwrap(); let cals_server = provider.remote().get_calendars().await.unwrap();
println!("----Server-------"); println!("----Server, after sync-------");
my_tasks::utils::print_calendar_list(&cals_server).await; my_tasks::utils::print_calendar_list(&cals_server).await;
let cals_local = provider.local().get_calendars().await.unwrap(); let cals_local = provider.local().get_calendars().await.unwrap();
println!("\n----Local-------"); println!("\n----Local, after sync-------");
my_tasks::utils::print_calendar_list(&cals_local).await; my_tasks::utils::print_calendar_list(&cals_local).await;
assert!(provider.remote().has_same_contents_than(provider.local()).await.unwrap()); assert!(provider.remote().has_same_contents_than(provider.local()).await.unwrap());