Skip to content

test: add tests for LatestPatchsets functions#155

Merged
lorenzoberts merged 3 commits intokworkflow:unstablefrom
lorenzoberts:lorenzo/refactor-latests-patchsets-struct
Sep 20, 2025
Merged

test: add tests for LatestPatchsets functions#155
lorenzoberts merged 3 commits intokworkflow:unstablefrom
lorenzoberts:lorenzo/refactor-latests-patchsets-struct

Conversation

@lorenzoberts
Copy link
Collaborator

This PR aims to continue increasing test coverage within patch-hub. The LatestPatchsets functions had no tests because we couldn't instantiate a mocked BlockingLoreAPIClient. To solve that, I have changed the structure to depend directly on the trait PatchFeedRequest, 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.

@lorenzoberts lorenzoberts force-pushed the lorenzo/refactor-latests-patchsets-struct branch from f9fc447 to 3d0151d Compare September 20, 2025 14:05
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>
@lorenzoberts lorenzoberts force-pushed the lorenzo/refactor-latests-patchsets-struct branch from 3d0151d to fd85238 Compare September 20, 2025 14:20
@lorenzoberts lorenzoberts merged commit fd85238 into kworkflow:unstable Sep 20, 2025
4 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.

1 participant