diff --git a/src/cache.rs b/src/cache.rs index cea07bd..bfec075 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -143,6 +143,7 @@ impl Cache { /// Compares two Caches to check they have the same current content /// /// This is not a complete equality test: some attributes (sync status...) may differ. This should mostly be used in tests + #[cfg(any(test, feature = "integration_tests"))] pub async fn has_same_observable_content_as(&self, other: &Self) -> Result> { let calendars_l = self.get_calendars().await?; let calendars_r = other.get_calendars().await?; diff --git a/src/calendar/cached_calendar.rs b/src/calendar/cached_calendar.rs index fa8b381..e0da5c4 100644 --- a/src/calendar/cached_calendar.rs +++ b/src/calendar/cached_calendar.rs @@ -59,6 +59,7 @@ impl CachedCalendar { } /// Some kind of equality check + #[cfg(any(test, feature = "integration_tests"))] pub async fn has_same_observable_content_as(&self, other: &CachedCalendar) -> Result> { if self.name != other.name || self.id != other.id diff --git a/src/event.rs b/src/event.rs index 6287be9..23bdc52 100644 --- a/src/event.rs +++ b/src/event.rs @@ -47,6 +47,7 @@ impl Event { self.sync_status = new_status; } + #[cfg(any(test, feature = "integration_tests"))] pub fn has_same_observable_content_as(&self, _other: &Event) -> bool { unimplemented!(); } diff --git a/src/item.rs b/src/item.rs index 77365d0..87512ac 100644 --- a/src/item.rs +++ b/src/item.rs @@ -103,10 +103,11 @@ impl Item { } } + #[cfg(any(test, feature = "integration_tests"))] pub fn has_same_observable_content_as(&self, other: &Item) -> bool { match (self, other) { (Item::Event(s), Item::Event(o)) => s.has_same_observable_content_as(o), - (Item::Task(s), Item::Task(o)) => s.has_same_observable_content_as(o), + (Item::Task(s), Item::Task(o)) => s.has_same_observable_content_as(o), _ => false, } } diff --git a/src/task.rs b/src/task.rs index d5d6ddb..f02e58f 100644 --- a/src/task.rs +++ b/src/task.rs @@ -92,13 +92,15 @@ impl Task { pub fn creation_date(&self) -> Option<&DateTime> { self.creation_date.as_ref() } pub fn completion_status(&self) -> &CompletionStatus { &self.completion_status } + #[cfg(any(test, feature = "integration_tests"))] pub fn has_same_observable_content_as(&self, other: &Task) -> bool { self.id == other.id && self.name == other.name - && self.completion_status == other.completion_status - && self.last_modified == other.last_modified // sync status must be the same variant, but we ignore its embedded version tag && std::mem::discriminant(&self.sync_status) == std::mem::discriminant(&other.sync_status) + // completion status must be the same variant, but we ignore its embedded completion date (they are not totally mocked in integration tests) + && std::mem::discriminant(&self.completion_status) == std::mem::discriminant(&other.completion_status) + // last modified dates are ignored (they are not totally mocked in integration tests) } pub fn set_sync_status(&mut self, new_status: SyncStatus) { @@ -135,6 +137,7 @@ impl Task { /// Rename a task, but forces a "master" SyncStatus, just like CalDAV servers are always "masters" pub fn mock_remote_calendar_set_name(&mut self, new_name: String) { self.sync_status = SyncStatus::random_synced(); + self.update_last_modified(); self.name = new_name; }