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

fix(common): LinkedChunk emits an Update::NewItemsChunk when constructed #4327

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Nov 26, 2024

This patch updates LinkedChunk::new_with_update_history to emit an Update::NewItemsChunk because the first chunk is created and it must emit an update accordingly.

The fix is 9 lines changes, the rest is only test updates.


…tructed.

This patch updates `LinkedChunk::new_with_update_history` to emit an
`Update::NewItemsChunk` because the first chunk is created and it must
emit an update accordingly.
@Hywan Hywan changed the title fix(common): LinkedChunk emits an Update::NewItemsChunk when constucted fix(common): LinkedChunk emits an Update::NewItemsChunk when constructed Nov 26, 2024
@Hywan Hywan marked this pull request as ready for review November 26, 2024 15:12
@Hywan Hywan requested a review from a team as a code owner November 26, 2024 15:12
@Hywan Hywan requested review from jmartinesp and bnjbvr and removed request for a team and jmartinesp November 26, 2024 15:12
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

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

Project coverage is 85.11%. Comparing base (75d7d07) to head (e7143d8).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk-common/src/linked_chunk/mod.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4327      +/-   ##
==========================================
+ Coverage   85.05%   85.11%   +0.05%     
==========================================
  Files         275      275              
  Lines       30309    30315       +6     
==========================================
+ Hits        25780    25802      +22     
+ Misses       4529     4513      -16     

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

Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Sweet, thanks!

#[test]
fn test_push_items() {
use super::Update::*;

let mut linked_chunk = LinkedChunk::<3, char, ()>::new_with_update_history();

// Ignore initial update.
let _ = linked_chunk.updates().unwrap().take();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could also check (here and everywhere below) that the initial update is what we expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

We have a specific test just for that: it builds a LinkedChunk and test the initial state. It helps to not repeat this for all tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's the test_new_with_initial_update test, just above this one.

@Hywan Hywan merged commit 37f52e1 into matrix-org:main Nov 27, 2024
76 checks passed
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.

linked chunk: the initial chunk isn't forwarded as part of the updates
2 participants