mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
test(event-cache): move test_linked_chunk_detach_last_items to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
@@ -159,6 +159,9 @@ pub trait EventCacheStoreIntegrationTests {
|
||||
/// Test remove an item from a linked chunk.
|
||||
async fn test_linked_chunk_remove_item(&self);
|
||||
|
||||
/// Test detaching last items from a linked chunk.
|
||||
async fn test_linked_chunk_detach_last_items(&self);
|
||||
|
||||
/// Test that rebuilding a linked chunk from an empty store doesn't return
|
||||
/// anything.
|
||||
async fn test_rebuild_empty_linked_chunk(&self);
|
||||
@@ -825,6 +828,42 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
|
||||
});
|
||||
}
|
||||
|
||||
async fn test_linked_chunk_detach_last_items(&self) {
|
||||
let room_id = *DEFAULT_TEST_ROOM_ID;
|
||||
let linked_chunk_id = LinkedChunkId::Room(room_id);
|
||||
|
||||
self.handle_linked_chunk_updates(
|
||||
linked_chunk_id,
|
||||
vec![
|
||||
Update::NewItemsChunk { previous: None, new: CId::new(42), next: None },
|
||||
Update::PushItems {
|
||||
at: Position::new(CId::new(42), 0),
|
||||
items: vec![
|
||||
make_test_event(room_id, "hello"),
|
||||
make_test_event(room_id, "world"),
|
||||
make_test_event(room_id, "howdy"),
|
||||
],
|
||||
},
|
||||
Update::DetachLastItems { at: Position::new(CId::new(42), 1) },
|
||||
],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut chunks = self.load_all_chunks(linked_chunk_id).await.unwrap();
|
||||
|
||||
assert_eq!(chunks.len(), 1);
|
||||
|
||||
let c = chunks.remove(0);
|
||||
assert_eq!(c.identifier, CId::new(42));
|
||||
assert_eq!(c.previous, None);
|
||||
assert_eq!(c.next, None);
|
||||
assert_matches!(c.content, ChunkContent::Items(events) => {
|
||||
assert_eq!(events.len(), 1);
|
||||
check_test_event(&events[0], "hello");
|
||||
});
|
||||
}
|
||||
|
||||
async fn test_rebuild_empty_linked_chunk(&self) {
|
||||
// When I rebuild a linked chunk from an empty store, it's empty.
|
||||
let linked_chunk = lazy_loader::from_all_chunks::<3, _, _>(
|
||||
@@ -1632,6 +1671,13 @@ macro_rules! event_cache_store_integration_tests {
|
||||
event_cache_store.test_linked_chunk_remove_item().await;
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_linked_chunk_detach_last_items() {
|
||||
let event_cache_store =
|
||||
get_event_cache_store().await.unwrap().into_event_cache_store();
|
||||
event_cache_store.test_linked_chunk_detach_last_items().await;
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_rebuild_empty_linked_chunk() {
|
||||
let event_cache_store =
|
||||
|
||||
@@ -57,36 +57,6 @@ pub async fn test_add_gap_chunk_and_delete_it_immediately(store: IndexeddbEventC
|
||||
assert_eq!(chunks.len(), 1);
|
||||
}
|
||||
|
||||
pub async fn test_linked_chunk_detach_last_items(store: IndexeddbEventCacheStore) {
|
||||
let room_id = &DEFAULT_TEST_ROOM_ID;
|
||||
let linked_chunk_id = LinkedChunkId::Room(room_id);
|
||||
let updates = vec![
|
||||
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(42), next: None },
|
||||
Update::PushItems {
|
||||
at: Position::new(ChunkIdentifier::new(42), 0),
|
||||
items: vec![
|
||||
make_test_event(room_id, "hello"),
|
||||
make_test_event(room_id, "world"),
|
||||
make_test_event(room_id, "howdy"),
|
||||
],
|
||||
},
|
||||
Update::DetachLastItems { at: Position::new(ChunkIdentifier::new(42), 1) },
|
||||
];
|
||||
store.handle_linked_chunk_updates(linked_chunk_id, updates).await.unwrap();
|
||||
|
||||
let mut chunks = store.load_all_chunks(linked_chunk_id).await.unwrap();
|
||||
assert_eq!(chunks.len(), 1);
|
||||
|
||||
let c = chunks.remove(0);
|
||||
assert_eq!(c.identifier, ChunkIdentifier::new(42));
|
||||
assert_eq!(c.previous, None);
|
||||
assert_eq!(c.next, None);
|
||||
assert_matches!(c.content, ChunkContent::Items(events) => {
|
||||
assert_eq!(events.len(), 1);
|
||||
check_test_event(&events[0], "hello");
|
||||
});
|
||||
}
|
||||
|
||||
pub async fn test_linked_chunk_start_end_reattach_items(store: IndexeddbEventCacheStore) {
|
||||
let room_id = &DEFAULT_TEST_ROOM_ID;
|
||||
let linked_chunk_id = LinkedChunkId::Room(room_id);
|
||||
@@ -388,12 +358,6 @@ macro_rules! indexeddb_event_cache_store_integration_tests {
|
||||
.await
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_linked_chunk_detach_last_items() {
|
||||
let store = get_event_cache_store().await.expect("Failed to get event cache store");
|
||||
$crate::event_cache_store::integration_tests::test_linked_chunk_detach_last_items(store).await
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_linked_chunk_start_end_reattach_items() {
|
||||
let store = get_event_cache_store().await.expect("Failed to get event cache store");
|
||||
|
||||
@@ -1741,50 +1741,6 @@ mod tests {
|
||||
assert_eq!(num_rows, 3);
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_linked_chunk_detach_last_items() {
|
||||
let store = get_event_cache_store().await.expect("creating cache store failed");
|
||||
|
||||
let room_id = *DEFAULT_TEST_ROOM_ID;
|
||||
let linked_chunk_id = LinkedChunkId::Room(room_id);
|
||||
|
||||
store
|
||||
.handle_linked_chunk_updates(
|
||||
linked_chunk_id,
|
||||
vec![
|
||||
Update::NewItemsChunk {
|
||||
previous: None,
|
||||
new: ChunkIdentifier::new(42),
|
||||
next: None,
|
||||
},
|
||||
Update::PushItems {
|
||||
at: Position::new(ChunkIdentifier::new(42), 0),
|
||||
items: vec![
|
||||
make_test_event(room_id, "hello"),
|
||||
make_test_event(room_id, "world"),
|
||||
make_test_event(room_id, "howdy"),
|
||||
],
|
||||
},
|
||||
Update::DetachLastItems { at: Position::new(ChunkIdentifier::new(42), 1) },
|
||||
],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut chunks = store.load_all_chunks(linked_chunk_id).await.unwrap();
|
||||
|
||||
assert_eq!(chunks.len(), 1);
|
||||
|
||||
let c = chunks.remove(0);
|
||||
assert_eq!(c.identifier, ChunkIdentifier::new(42));
|
||||
assert_eq!(c.previous, None);
|
||||
assert_eq!(c.next, None);
|
||||
assert_matches!(c.content, ChunkContent::Items(events) => {
|
||||
assert_eq!(events.len(), 1);
|
||||
check_test_event(&events[0], "hello");
|
||||
});
|
||||
}
|
||||
|
||||
#[async_test]
|
||||
async fn test_linked_chunk_start_end_reattach_items() {
|
||||
let store = get_event_cache_store().await.expect("creating cache store failed");
|
||||
|
||||
Reference in New Issue
Block a user