Skip to content

Power policy mocks refactor#903

Open
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:power-policy-mocks-refactor
Open

Power policy mocks refactor#903
RobertZ2011 wants to merge 2 commits into
OpenDevicePartnership:mainfrom
RobertZ2011:power-policy-mocks-refactor

Conversation

@RobertZ2011

@RobertZ2011 RobertZ2011 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Rename existing mocks crate to power-policy-interface-test-mocks and clean-up the module structure. Then update the mocks to match how mocks are implemented in type-c-interface-test-mocks

@RobertZ2011 RobertZ2011 self-assigned this Jun 24, 2026
@RobertZ2011 RobertZ2011 force-pushed the power-policy-mocks-refactor branch 2 times, most recently from f8592d0 to 1af2157 Compare June 24, 2026 20:47
@RobertZ2011 RobertZ2011 requested a review from Copilot June 24, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 and power-policy-service dev-dependencies.
  • Updates power-policy service tests to assert behavior via fn_calls queues (and configured next_result_* responses) instead of Signal + 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.

Comment thread power-policy-service/tests/common/mod.rs
Comment thread power-policy-interface-test-mocks/src/psu.rs
Comment thread power-policy-interface-test-mocks/src/psu.rs
Comment thread power-policy-interface-test-mocks/src/psu.rs
@RobertZ2011 RobertZ2011 force-pushed the power-policy-mocks-refactor branch 2 times, most recently from d60f67d to 1215ee0 Compare June 24, 2026 21:06
@RobertZ2011 RobertZ2011 marked this pull request as ready for review June 24, 2026 21:21
@RobertZ2011 RobertZ2011 requested review from a team as code owners June 24, 2026 21:21
…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
@RobertZ2011 RobertZ2011 force-pushed the power-policy-mocks-refactor branch from 1215ee0 to 4ba05b7 Compare June 25, 2026 18:00
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