Skip to content

Parameterize api-core's cross-entity test duplication #2699

@chet

Description

@chet

api-core re-proves the same behavior once per entity, which inflates the suite without adding coverage. Two patterns dominate: every find_*_by_ids RPC has its own "at least one id" / "no more than N ids" guard test (~18 across 10+ entities), all asserting byte-identical messages; and the health-override CRUD suite is implemented fn-for-fn three times (power_shelf, switch, rack). This consolidates both. The broader #[sqlx_test] integration tests that exercise distinct per-entity logic are out of scope -- they legitimately stay separate.

This is the heaviest item in Wave 1; if the diff gets unwieldy it can split into two PRs (guards; CRUD), with a linked issue opened for the second.

Scope

  • Guards: replace the per-entity *_by_ids_none / *_by_ids_over_max tests (tests/*_find.rs) with one canonical test per guard, or a parameterized table keyed on a per-RPC closure. The guard runs in the API layer ahead of the DB, so it does not need re-proving per entity.
  • Health-override CRUD: parameterize the power_shelf_health / switch_health / rack_health suites (tests/) into one generic harness over (insert/list/remove/find fns, metric prefix, alert id); keep rack_health's unique propagation/precedence tests.
  • component_manager: collapse the power_action_* (6) and error_to_status_* (5) per-variant tests into tables (handlers/component_manager.rs) -- the latter also adds the currently-missing Transport / Rms arms.

Acceptance

  • Each guard is proven once; the health CRUD suite runs through one harness; coverage preserved or improved (component_manager gains Transport / Rms).
  • cargo test green for api-core; cargo clippy --all-features clean.

Size: M-L

Part of #2692.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions