use matrix_sdk_base::{
event_cache::store::EventCacheStore,
linked_chunk::{ChunkIdentifier, LinkedChunkId, Update},
};
use matrix_sdk_test::DEFAULT_TEST_ROOM_ID;
use crate::event_cache_store::IndexeddbEventCacheStore;
pub async fn test_linked_chunk_update_is_a_transaction(store: IndexeddbEventCacheStore) {
let linked_chunk_id = LinkedChunkId::Room(*DEFAULT_TEST_ROOM_ID);
let updates = vec![
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(42), next: None },
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(42), next: None },
];
store.handle_linked_chunk_updates(linked_chunk_id, updates).await.unwrap_err();
let chunks = store.load_all_chunks(linked_chunk_id).await.unwrap();
assert!(chunks.is_empty());
}
#[macro_export]
macro_rules! indexeddb_event_cache_store_integration_tests {
() => {
mod indexeddb_event_cache_store_integration_tests {
use matrix_sdk_test::async_test;
use super::get_event_cache_store;
#[async_test]
async fn test_linked_chunk_update_is_a_transaction() {
let store = get_event_cache_store().await.expect("Failed to get event cache store");
$crate::event_cache_store::integration_tests::test_linked_chunk_update_is_a_transaction(store)
.await
}
}
};
}