Skip to content

refactor(sdk): Convert some tests to the MatrixMockServer and MockClientBuilder APIs #5351

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

Merged
merged 6 commits into from
Jul 7, 2025

Conversation

zecakeh
Copy link
Collaborator

@zecakeh zecakeh commented Jul 4, 2025

There are a handful of commits to improve the APIs first, and then all the tests from crates/matrix-sdk/src/client/mod.rs, crates/matrix-sdk/src/sliding_sync/client.rs and crates/matrix-sdk/tests/integration/media.rs are converted to those APIs.

Note that those 3 files were not chosen randomly, some of the tests there fail in #5337, and one of the simplest solutions for fixing them involves porting them to the newer APIs.

This can be reviewed commit by commit.

@zecakeh zecakeh requested a review from a team as a code owner July 4, 2025 14:50
@zecakeh zecakeh requested review from poljar and removed request for a team July 4, 2025 14:50
@zecakeh zecakeh force-pushed the tests-mock-apis branch from 7ea23d7 to 67e105a Compare July 4, 2025 15:45
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

Attention: Patch coverage is 95.94203% with 14 lines in your changes missing coverage. Please review.

Project coverage is 88.73%. Comparing base (f9e7d16) to head (277b123).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/test_utils/mocks/mod.rs 94.00% 9 Missing ⚠️
crates/matrix-sdk/src/test_utils/client.rs 81.48% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5351      +/-   ##
==========================================
- Coverage   88.76%   88.73%   -0.03%     
==========================================
  Files         333      333              
  Lines       90326    90381      +55     
  Branches    90326    90381      +55     
==========================================
+ Hits        80177    80204      +27     
- Misses       6325     6352      +27     
- Partials     3824     3825       +1     

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

zecakeh added 3 commits July 5, 2025 02:30
Usually tests that don't construct it via MockMatrixServer don't care
about the homeserver URL, so this allows to provide a default URL for
them.

Also we don't force to allocate a string when the inner API actually
uses a borrowed string.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Since there are several places that use it.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
…f MockClientBuilder

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
@zecakeh zecakeh changed the title refactor(sdk): Convert some tests to the MockMatrixServer and MockClientBuilder APIs refactor(sdk): Convert some tests to the MatrixMockServer and MockClientBuilder APIs Jul 5, 2025
zecakeh added 3 commits July 5, 2025 10:43
…ilder

Because it's such a nicer API!

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
…Builder

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
…Builder

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
@zecakeh zecakeh force-pushed the tests-mock-apis branch from 67e105a to 277b123 Compare July 5, 2025 08:43
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.

Reeaaaaaallly nice, thanks!

@Hywan Hywan merged commit 049993d into matrix-org:main Jul 7, 2025
44 checks passed
@zecakeh zecakeh deleted the tests-mock-apis branch July 7, 2025 08:20
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