Power policy mocks refactor#903
Open
RobertZ2011 wants to merge 2 commits into
Open
Conversation
f8592d0 to
1af2157
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors power-policy-service tests to use a new shared power-policy-interface-test-mocks crate for PSU/charger mocking, replacing the previous per-test Signal-based call tracking with recorded call queues and pre-programmed return values.
Changes:
- Introduces
power-policy-interface-test-mocks(PSU + charger mocks) and wires it into the workspace andpower-policy-servicedev-dependencies. - Updates power-policy service tests to assert behavior via
fn_callsqueues (and configurednext_result_*responses) instead ofSignal+ per-call timeouts. - Updates CI to exclude the new std-only mocks crate from embedded-target checks.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| power-policy-service/tests/unconstrained.rs | Migrates unconstrained-flow tests from Signal waits to fn_calls assertions and queued results. |
| power-policy-service/tests/provider.rs | Migrates provider-flow tests to new mock call recording and queued results. |
| power-policy-service/tests/consumer.rs | Migrates consumer-flow tests to new mock call recording; adds small delays where no events are expected. |
| power-policy-service/tests/common/mod.rs | Switches shared test harness to use new mock types; adds a default “no event expected” delay constant. |
| power-policy-service/tests/common/mock.rs | Removes the old in-crate mock implementation (replaced by shared mocks crate). |
| power-policy-service/Cargo.toml | Adds power-policy-interface-test-mocks as a dev-dependency for tests. |
| power-policy-interface-test-mocks/src/psu.rs | Adds PSU mock with call recording and queued next-result behavior. |
| power-policy-interface-test-mocks/src/charger.rs | Adds charger mock with call recording and queued next-result behavior. |
| power-policy-interface-test-mocks/src/lib.rs | Exposes the new mocks modules. |
| power-policy-interface-test-mocks/Cargo.toml | Defines the new mocks crate and its dependencies. |
| Cargo.toml | Adds the new mocks crate to workspace members and workspace dependencies. |
| Cargo.lock | Adds the new crate entries and links it into power-policy-service dev graph. |
| .github/workflows/check.yml | Excludes the new std-only mocks crate from embedded-target jobs via STD_EXCLUDED_CRATES. |
d60f67d to
1215ee0
Compare
…rate Move PSU and charger mock code from power-policy-service/tests/common/mock.rs into a standalone power-policy-interface-test-mocks crate with separate psu and charger modules. Update workspace configuration, CI workflow exclusions, and test imports accordingly. Assisted-by: GitHub Copilot:claude-opus-4.6
Follow the type-c-interface-mocks pattern for the PSU and charger mocks. Each mock now records its trait method invocations in a VecDeque of FnCall values and returns results from per-method `next_result_*` queues that tests populate before each action. This replaces the previous Signal-based synchronization and lets tests assert on the exact sequence of calls made by the service. The charger mock is also made generic over NonBlockingSender to match the PSU mock and the service's event-driven architecture. Assisted-by: GitHub Copilot:claude-opus-4.8
1215ee0 to
4ba05b7
Compare
dymk
approved these changes
Jun 26, 2026
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.
Rename existing mocks crate to
power-policy-interface-test-mocksand clean-up the module structure. Then update the mocks to match how mocks are implemented intype-c-interface-test-mocks