Skip to content

Consolidate the duplicated CRUD and IP-candidate test trios in api-db and health #2698

@chet

Description

@chet

api-db and health carry duplication the helper was meant to remove: the same expected-entity CRUD suite written once per entity, an IP-candidate trio that differs only by input, and two tests that can't fail. Consolidate the trios into a shared helper or a table and drop the dead ones. Test-only; no behavior change.

Scope

api-db

  • Merge the three expected_{machine,switch,power_shelf} CRUD suites -- test_lookup_by_mac, test_duplicate_fail_create, test_update_bmc_credentials, test_delete, identical modulo entity -- into a shared generic helper (each #[sqlx_test] still needs its own pool, so this is a parameterized helper, not a single table).
  • Collapse the IPv4 candidate trio into one check_cases table (ip_allocator.rs); keep test_v4_single_ip_candidate (distinct).
  • Drop the pure ORM round-trips in expected_rack/tests.rs (insert then read back unchanged).

health

  • Delete test_should_monitor_key_consistency (sharding.rs) -- it asserts f(x) == f(x).
  • Fix or delete test_sync_with_duplicate_addresses_in_input (route_servers.rs) -- it declares both Ok and Err acceptable, so it cannot fail; if there's a real uniqueness contract, assert it.

Acceptance

  • The three CRUD suites run through one shared helper; coverage preserved.
  • cargo test green for both crates; cargo clippy --all-features clean.

Size: S-M

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