power-policy-service/tests: Introduce dedicated Test trait#772
Open
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
Open
power-policy-service/tests: Introduce dedicated Test trait#772RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors power-policy-service integration tests to use a dedicated Test trait (instead of generic FnOnce/closure plumbing) and extends the test harness to accept a Config, enabling coverage of configuration-dependent behavior.
Changes:
- Replaces per-test async functions with
structtest cases implementingcommon::Test. - Updates
run_testto take apower_policy_service::service::config::Configand wires it intoService::new. - Adds new consumer test coverage for
min_consumer_threshold_mwand “no swap on equal capability”.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| power-policy-service/tests/common/mod.rs | Introduces Test trait + adds Config parameter to run_test + adds MINIMAL_POWER constant. |
| power-policy-service/tests/consumer.rs | Refactors to Test structs and adds tests for minimum-consumer-threshold and no-swap behavior. |
| power-policy-service/tests/provider.rs | Refactors provider tests to Test structs and updates run_test calls for new signature. |
| power-policy-service/tests/unconstrained.rs | Refactors unconstrained test to Test struct and updates run_test call. |
The existing traits used to resolve lifetime issues with test closures are messy and difficult to understand. Introduce a dedicated `Test` trait to make things cleaner.
de84539 to
c3effbe
Compare
jerrysxie
approved these changes
Apr 2, 2026
| ( | ||
| 1, | ||
| FnCall::ConnectConsumer(ConsumerPowerCapability { | ||
| pub struct TestSwapHigher; |
Contributor
There was a problem hiding this comment.
Does this need to be pub? It seems like it is only used in this file.
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.
The existing traits used to resolve lifetime issues with test closures are messy and difficult to understand. Introduce a dedicated
Testtrait to make things cleaner.This PR is smaller than it seems, but a lot of lines were touched due to the formatting changes required with moving the previously free functions into traits.