Major overhaul: more generics!

This commit is contained in:
daladim 2021-03-01 23:39:16 +01:00
parent eaa6d8a61e
commit caaddf910c
12 changed files with 314 additions and 163 deletions

View file

@ -7,6 +7,8 @@ use minidom::Element;
use url::Url;
use my_tasks::client::Client;
use my_tasks::traits::PartialCalendar;
use my_tasks::settings::URL;
use my_tasks::settings::USERNAME;
use my_tasks::settings::PASSWORD;
@ -24,7 +26,7 @@ static EXAMPLE_TASKS_BODY_LAST_MODIFIED: &str = r#"
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VTODO">
<C:prop-filter name="LAST-MODIFIED">
<C:time-range start="20210220T000000Z"
<C:time-range start="20210228T002308Z"
end="20260105T000000Z"/>
</C:prop-filter>
</C:comp-filter>
@ -45,7 +47,7 @@ async fn test_client() {
.map(|cal| println!(" {}\t{}", cal.name(), cal.url().as_str()))
.collect::<()>();
let _ = client.get_tasks(&calendars[3].url()).await;
let _ = client.get_tasks(&calendars[0].url()).await;
}
#[tokio::test]

View file

@ -4,10 +4,11 @@ use chrono::{Utc, TimeZone};
use url::Url;
use my_tasks::traits::CalDavSource;
use my_tasks::traits::{PartialCalendar, CompleteCalendar};
use my_tasks::cache::Cache;
use my_tasks::Item;
use my_tasks::Task;
use my_tasks::Calendar;
use my_tasks::calendar::cached_calendar::CachedCalendar;
use my_tasks::Provider;
#[tokio::test]
@ -44,7 +45,7 @@ async fn test_sync() {
/// * X': name has been modified since the last sync
/// * F'/F'': name conflict
/// * G✓: task has been marked as completed
async fn populate_test_provider() -> Provider<Cache, Cache> {
async fn populate_test_provider() -> Provider<Cache, CachedCalendar, Cache, CachedCalendar> {
let mut server = Cache::new(&PathBuf::from(String::from("server.json")));
let mut local = Cache::new(&PathBuf::from(String::from("local.json")));
@ -80,7 +81,7 @@ async fn populate_test_provider() -> Provider<Cache, Cache> {
// Step 1
// Build the calendar as it was at the time of the sync
let mut calendar = Calendar::new("a list".into(), Url::parse("http://todo.list/cal").unwrap(), my_tasks::calendar::SupportedComponents::TODO);
let mut calendar = CachedCalendar::new("a list".into(), Url::parse("http://todo.list/cal").unwrap(), my_tasks::calendar::SupportedComponents::TODO);
calendar.add_item(task_a);
calendar.add_item(task_b);
calendar.add_item(task_c);