Skip to content

Commit ab81388

Browse files
mgoldenbergHywan
authored andcommitted
test(indexeddb): add event cache store integration tests
Signed-off-by: Michael Goldenberg <[email protected]>
1 parent c5436ed commit ab81388

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

crates/matrix-sdk-indexeddb/src/event_cache_store/integration_tests.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,49 @@ macro_rules! indexeddb_event_cache_store_integration_tests {
550550
}
551551
};
552552
}
553+
554+
// This is copied from `matrix_sdk_base::event_cache::store::integration_tests`
555+
// for the time being, because the IndexedDB implementation of `EventCacheStore`
556+
// is being completed iteratively. So, we are only bringing over the tests
557+
// relevant to the implemented functions. At the moment, this includes the
558+
// following.
559+
//
560+
// - EventCacheStore::handle_linked_chunk_updates
561+
// - EventCacheStore::load_all_chunks
562+
//
563+
// When all functions are implemented, we can get rid of this macro and use the
564+
// one from `matrix_sdk_base`.
565+
#[macro_export]
566+
macro_rules! event_cache_store_integration_tests {
567+
() => {
568+
mod event_cache_store_integration_tests {
569+
use matrix_sdk_base::event_cache::store::{
570+
EventCacheStoreIntegrationTests, IntoEventCacheStore,
571+
};
572+
use matrix_sdk_test::async_test;
573+
574+
use super::get_event_cache_store;
575+
576+
#[async_test]
577+
async fn test_handle_updates_and_rebuild_linked_chunk() {
578+
let event_cache_store =
579+
get_event_cache_store().await.unwrap().into_event_cache_store();
580+
event_cache_store.test_handle_updates_and_rebuild_linked_chunk().await;
581+
}
582+
583+
#[async_test]
584+
async fn test_rebuild_empty_linked_chunk() {
585+
let event_cache_store =
586+
get_event_cache_store().await.unwrap().into_event_cache_store();
587+
event_cache_store.test_rebuild_empty_linked_chunk().await;
588+
}
589+
590+
#[async_test]
591+
async fn test_remove_room() {
592+
let event_cache_store =
593+
get_event_cache_store().await.unwrap().into_event_cache_store();
594+
event_cache_store.test_remove_room().await;
595+
}
596+
}
597+
};
598+
}

crates/matrix-sdk-indexeddb/src/event_cache_store/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,12 @@ impl_event_cache_store! {
468468
#[cfg(test)]
469469
mod tests {
470470
use matrix_sdk_base::event_cache::store::{EventCacheStore, EventCacheStoreError};
471+
use matrix_sdk_test::async_test;
471472
use uuid::Uuid;
472473

473474
use crate::{
474-
event_cache_store::IndexeddbEventCacheStore, indexeddb_event_cache_store_integration_tests,
475+
event_cache_store::IndexeddbEventCacheStore, event_cache_store_integration_tests,
476+
indexeddb_event_cache_store_integration_tests,
475477
};
476478

477479
mod unencrypted {
@@ -484,6 +486,10 @@ mod tests {
484486
Ok(IndexeddbEventCacheStore::builder().database_name(name).build().await?)
485487
}
486488

489+
#[cfg(target_family = "wasm")]
490+
event_cache_store_integration_tests!();
491+
492+
#[cfg(target_family = "wasm")]
487493
indexeddb_event_cache_store_integration_tests!();
488494
}
489495

@@ -497,6 +503,10 @@ mod tests {
497503
Ok(IndexeddbEventCacheStore::builder().database_name(name).build().await?)
498504
}
499505

506+
#[cfg(target_family = "wasm")]
507+
event_cache_store_integration_tests!();
508+
509+
#[cfg(target_family = "wasm")]
500510
indexeddb_event_cache_store_integration_tests!();
501511
}
502512
}

0 commit comments

Comments
 (0)