Skip to content

power-policy-service/tests: Introduce dedicated Test trait#772

Open
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-test-trait
Open

power-policy-service/tests: Introduce dedicated Test trait#772
RobertZ2011 wants to merge 1 commit intoOpenDevicePartnership:v0.2.0from
RobertZ2011:power-policy-test-trait

Conversation

@RobertZ2011
Copy link
Copy Markdown
Contributor

@RobertZ2011 RobertZ2011 commented Apr 1, 2026

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.

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.

@RobertZ2011 RobertZ2011 self-assigned this Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 17:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 struct test cases implementing common::Test.
  • Updates run_test to take a power_policy_service::service::config::Config and wires it into Service::new.
  • Adds new consumer test coverage for min_consumer_threshold_mw and “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.
@RobertZ2011 RobertZ2011 force-pushed the power-policy-test-trait branch from de84539 to c3effbe Compare April 1, 2026 17:30
@RobertZ2011 RobertZ2011 changed the title Power policy test trait power-policy-service/tests: Introduce dedicated Test trait Apr 1, 2026
@RobertZ2011 RobertZ2011 marked this pull request as ready for review April 1, 2026 18:01
@RobertZ2011 RobertZ2011 requested review from a team as code owners April 1, 2026 18:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@github-project-automation github-project-automation bot moved this to In progress in ODP Backlog Apr 2, 2026
(
1,
FnCall::ConnectConsumer(ConsumerPowerCapability {
pub struct TestSwapHigher;
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.

Does this need to be pub? It seems like it is only used in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants