A function is only useful in tests
This commit is contained in:
parent
d9b11a30ec
commit
5b1adca42c
5 changed files with 10 additions and 3 deletions
|
@ -143,6 +143,7 @@ impl Cache {
|
||||||
/// Compares two Caches to check they have the same current content
|
/// 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
|
/// 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<bool, Box<dyn Error>> {
|
pub async fn has_same_observable_content_as(&self, other: &Self) -> Result<bool, Box<dyn Error>> {
|
||||||
let calendars_l = self.get_calendars().await?;
|
let calendars_l = self.get_calendars().await?;
|
||||||
let calendars_r = other.get_calendars().await?;
|
let calendars_r = other.get_calendars().await?;
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl CachedCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Some kind of equality check
|
/// Some kind of equality check
|
||||||
|
#[cfg(any(test, feature = "integration_tests"))]
|
||||||
pub async fn has_same_observable_content_as(&self, other: &CachedCalendar) -> Result<bool, Box<dyn Error>> {
|
pub async fn has_same_observable_content_as(&self, other: &CachedCalendar) -> Result<bool, Box<dyn Error>> {
|
||||||
if self.name != other.name
|
if self.name != other.name
|
||||||
|| self.id != other.id
|
|| self.id != other.id
|
||||||
|
|
|
@ -47,6 +47,7 @@ impl Event {
|
||||||
self.sync_status = new_status;
|
self.sync_status = new_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "integration_tests"))]
|
||||||
pub fn has_same_observable_content_as(&self, _other: &Event) -> bool {
|
pub fn has_same_observable_content_as(&self, _other: &Event) -> bool {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,10 +103,11 @@ impl Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "integration_tests"))]
|
||||||
pub fn has_same_observable_content_as(&self, other: &Item) -> bool {
|
pub fn has_same_observable_content_as(&self, other: &Item) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Item::Event(s), Item::Event(o)) => s.has_same_observable_content_as(o),
|
(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,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,13 +92,15 @@ impl Task {
|
||||||
pub fn creation_date(&self) -> Option<&DateTime<Utc>> { self.creation_date.as_ref() }
|
pub fn creation_date(&self) -> Option<&DateTime<Utc>> { self.creation_date.as_ref() }
|
||||||
pub fn completion_status(&self) -> &CompletionStatus { &self.completion_status }
|
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 {
|
pub fn has_same_observable_content_as(&self, other: &Task) -> bool {
|
||||||
self.id == other.id
|
self.id == other.id
|
||||||
&& self.name == other.name
|
&& 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
|
// 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)
|
&& 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) {
|
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"
|
/// 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) {
|
pub fn mock_remote_calendar_set_name(&mut self, new_name: String) {
|
||||||
self.sync_status = SyncStatus::random_synced();
|
self.sync_status = SyncStatus::random_synced();
|
||||||
|
self.update_last_modified();
|
||||||
self.name = new_name;
|
self.name = new_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue