mirror of
https://github.com/stalwartlabs/stalwart.git
synced 2026-03-17 14:34:03 +00:00
Fix tests
This commit is contained in:
9
crates/email/src/cache/mod.rs
vendored
9
crates/email/src/cache/mod.rs
vendored
@@ -125,6 +125,7 @@ impl MessageCacheFetch for Server {
|
||||
let mut changed_items: AHashMap<u32, bool> = AHashMap::with_capacity(changes.changes.len());
|
||||
let mut changed_containers: AHashMap<u32, bool> =
|
||||
AHashMap::with_capacity(changes.changes.len());
|
||||
let mut has_container_property_changes = false;
|
||||
|
||||
for change in changes.changes {
|
||||
match change {
|
||||
@@ -156,7 +157,9 @@ impl MessageCacheFetch for Server {
|
||||
Change::DeleteContainer(id) => {
|
||||
changed_containers.insert(id as u32, false);
|
||||
}
|
||||
Change::UpdateContainerProperty(_) => (),
|
||||
Change::UpdateContainerProperty(_) => {
|
||||
has_container_property_changes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +175,10 @@ impl MessageCacheFetch for Server {
|
||||
update_mailbox_cache(self, account_id, &changed_containers, &cache).await?;
|
||||
mailbox_cache.change_id = changes.container_change_id.unwrap_or(changes.to_change_id);
|
||||
cache.mailboxes = Arc::new(mailbox_cache);
|
||||
} else if has_container_property_changes {
|
||||
let mut mailbox_cache = cache.mailboxes.as_ref().clone();
|
||||
mailbox_cache.change_id = changes.container_change_id.unwrap_or(changes.to_change_id);
|
||||
cache.mailboxes = Arc::new(mailbox_cache);
|
||||
}
|
||||
cache.size = cache.emails.size + cache.mailboxes.size;
|
||||
cache.last_change_id = changes.to_change_id;
|
||||
|
||||
@@ -803,7 +803,13 @@ impl Purge for Server {
|
||||
// SPDX-License-Identifier: LicenseRef-SEL
|
||||
#[cfg(feature = "enterprise")]
|
||||
if let Some(trace_retention) = trace_retention
|
||||
&& let Err(err) = store
|
||||
&& let Some(trace_store) = self
|
||||
.core
|
||||
.enterprise
|
||||
.as_ref()
|
||||
.and_then(|e| e.trace_store.as_ref())
|
||||
&& let Err(err) = trace_store
|
||||
.store
|
||||
.purge_spans(trace_retention, self.search_store().into())
|
||||
.await
|
||||
{
|
||||
@@ -812,7 +818,12 @@ impl Purge for Server {
|
||||
|
||||
#[cfg(feature = "enterprise")]
|
||||
if let Some(metrics_retention) = metrics_retention
|
||||
&& let Err(err) = store.purge_metrics(metrics_retention).await
|
||||
&& let Some(metrics_store) = self
|
||||
.core
|
||||
.enterprise
|
||||
.as_ref()
|
||||
.and_then(|e| e.metrics_store.as_ref())
|
||||
&& let Err(err) = metrics_store.store.purge_metrics(metrics_retention).await
|
||||
{
|
||||
trc::error!(err.details("Failed to purge metrics"));
|
||||
}
|
||||
|
||||
@@ -117,9 +117,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
if change_num % 2 == 0 {
|
||||
type1_ids.insert(jmap_id);
|
||||
}
|
||||
thread_id_map
|
||||
.entry(jmap_id.prefix_id())
|
||||
.or_insert(jmap_id);
|
||||
thread_id_map.entry(jmap_id.prefix_id()).or_insert(jmap_id);
|
||||
}
|
||||
LogAction::Update(id) => {
|
||||
let id = *id_map.get(id).unwrap();
|
||||
@@ -290,7 +288,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||
for item in changes.added() {
|
||||
let item_id = Id::from_str(item.id()).unwrap();
|
||||
let id = id_map.iter().find(|(_, v)| **v == item_id).unwrap().0;
|
||||
assert!(id < &7, "{:?} (id: {})", changes, id);
|
||||
assert!(id <= &7, "{:?} (id: {})", changes, id);
|
||||
}
|
||||
}
|
||||
if test_num == 4 {
|
||||
|
||||
Reference in New Issue
Block a user