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(event cache): keep the previous-batch token when we haven't enabled storage #4495

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jan 9, 2025

When we don't have enabled storage, we should keep all the previous-batch tokens, otherwise we'll miss events, lacking any form of caching.

Now with a test.

Part of #3280.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.36%. Comparing base (ca9eb70) to head (f51285a).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/test_utils/mocks.rs 82.60% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4495      +/-   ##
==========================================
- Coverage   85.36%   85.36%   -0.01%     
==========================================
  Files         284      284              
  Lines       31886    31903      +17     
==========================================
+ Hits        27219    27233      +14     
- Misses       4667     4670       +3     

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

This removes a few manual uses of `ResponseTemplate`, which is sweet and
guarantees some better typing for those responses overall.
@bnjbvr bnjbvr force-pushed the bnjbvr/store-prev-batch-token-if-no-storage branch from 9023340 to bb444d0 Compare January 13, 2025 11:56
@bnjbvr bnjbvr marked this pull request as ready for review January 13, 2025 11:57
@bnjbvr bnjbvr requested a review from a team as a code owner January 13, 2025 11:57
@bnjbvr bnjbvr requested review from Hywan and removed request for a team January 13, 2025 11:57
MatrixMock { server: self.server, mock }
}
}

/// A response to a [`RoomMessagesEndpoint`] query.
pub struct RoomMessagesResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call this a bit differently? It's not the real Ruma response we use everywhere else, it's a test helper. Perhaps RoomMessageResponseTemplate?

Copy link
Member

Choose a reason for hiding this comment

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

MockRoomMessages?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well we're not mocking, and it's not a message. It's about the response that you would send out if you were to send a room message. Then we pass that response to the mock server which will mock things for us.

I picked the Template naming because wiremock, which we use and wrap here, is using that term as well: https://docs.rs/wiremock/latest/wiremock/struct.ResponseTemplate.html#.

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 like RoomMessageResponseTemplate, thanks!

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Approving the real commit :-).

MatrixMock { server: self.server, mock }
}
}

/// A response to a [`RoomMessagesEndpoint`] query.
pub struct RoomMessagesResponse {
Copy link
Member

Choose a reason for hiding this comment

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

MockRoomMessages?

@bnjbvr bnjbvr enabled auto-merge (rebase) January 13, 2025 13:35
@bnjbvr bnjbvr merged commit 9514388 into main Jan 13, 2025
39 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/store-prev-batch-token-if-no-storage branch January 13, 2025 13:50
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.

3 participants