Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(event cache): rely less on EventCache::add_initial_events() #4372

Merged
merged 8 commits into from
Dec 4, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Dec 3, 2024

EventCache::add_initial_events() was supposed to be temporary, until the event cache has its own storage. It's been used in multiple tests, as a way to prefill the event cache. It's used in other place, when constructing a timeline, to prefill the room event cache with the (soon-to-be-deprecated) cached timeline we stored in the sliding sync storage (aka timeline_queue()).

This patch gets rids of all uses in tests, so that there remains only a single use (when creating the timeline). We can later remove this function, once the storage has been enabled unconditionally.

Part of #3280
Split from #4308.

@bnjbvr bnjbvr requested a review from a team as a code owner December 3, 2024 13:25
@bnjbvr bnjbvr requested review from poljar and removed request for a team December 3, 2024 13:25
@bnjbvr bnjbvr mentioned this pull request Dec 3, 2024
37 tasks
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.14%. Comparing base (74119e8) to head (bdda880).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/event_cache/mod.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4372   +/-   ##
=======================================
  Coverage   85.14%   85.14%           
=======================================
  Files         280      280           
  Lines       30764    30766    +2     
=======================================
+ Hits        26195    26197    +2     
  Misses       4569     4569           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 178 to 185
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(0), next: None },
Update::PushItems {
at: Position::new(ChunkIdentifier::new(0), 0),
items: vec![
f.text_msg("hey there").sender(dexter).into_sync(),
f.text_msg("hoy!").sender(ivan).into_sync(),
],
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we shouldn't use a builder for that 🤔, thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could even avoid that by using a sync, and let the event cache store the events in memory.

@bnjbvr bnjbvr force-pushed the bnjbvr/rely-less-on-add-initial-events branch from e8a4ce0 to bdda880 Compare December 4, 2024 10:50
@poljar poljar removed their request for review December 4, 2024 11:34
@bnjbvr bnjbvr merged commit e0b1b5d into main Dec 4, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/rely-less-on-add-initial-events branch December 4, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants