test: add tests for LatestPatchsets functions#155
Merged
lorenzoberts merged 3 commits intokworkflow:unstablefrom Sep 20, 2025
Merged
Conversation
f9fc447 to
3d0151d
Compare
This commit replaces the use of BlockingLoreAPIClient with the PatchFeedRequest trait in LatestPatchsets struct. The reason for this change is to make LatestPatchsets testable. By requiring a trait in the initialization, we can mock it instead of having to initialize the real lore api client. Signed-off-by: Lorenzo Bertin Salvador <lorenzobs@usp.br>
This commit adds tests to the LatestPatchsets' functions. One of the tests is commented because it would affect unrelated tests due to a bug. Signed-off-by: Lorenzo Bertin Salvador <lorenzobs@usp.br>
…) call This commit aims to solve a problem where a test would install the default error hook (by reaching a bail!, for example), before we install our custom hooks. This would make infrastructure/errors.rs tests fail because the custom hooks could not be installed. By using #[ctor::ctor] in main.rs we assure the custom hooks will be installed before any test runs. Signed-off-by: Lorenzo Bertin Salvador <lorenzobs@usp.br>
3d0151d to
fd85238
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to continue increasing test coverage within patch-hub. The
LatestPatchsetsfunctions had no tests because we couldn't instantiate a mockedBlockingLoreAPIClient. To solve that, I have changed the structure to depend directly on the traitPatchFeedRequest, this way it's possible to mock it.Besides that, when creating a test that reached a
bail!inside fetch_current_page, I realized we had a conflict between any tests that would trigger an error hook, and infrastructure tests that were testing our custom hooks.To solve this, I have added the ctor and once_cell as dev-dependencies and created a global hook initialization before any test is run. With this, the custom hooks are always installed and we can test them the same time other tests reach bail! or any function that might trigger the hooks.