test(api-db): Move DB-only API tests from api-core into api-db#2652
Conversation
Move machine interface IP allocation tests into api-db and replace API fixture setup with direct DB test setup for segments and domains. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Relocate domain create/delete/find/update tests from api-core into the api-db DNS domain module so they live with the database functionality they exercise. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Move power shelf, rack, and switch metadata tests into their respective api-db modules so they live alongside the database code they exercise. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Move the find-by-address test from api-core into the api-db machine interface address module, replacing the api-core fixture dependency with direct database setup. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Move the duplicate machine interface MAC test from api-core into the api-db machine interface module, and add shared test support for constructing admin network segments. Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Summary by CodeRabbit
WalkthroughA new crate-internal ChangesTest Infrastructure Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/api-db/src/machine_interface/test_duplicate_mac.rs (1)
73-73: ⚡ Quick winPrefer
rollback()for consistency with other tests.This test validates duplicate MAC detection (error handling) rather than the commit path. Other tests in this PR consistently use
txn.rollback().await?(seepower_shelf/test_metadata.rslines 53/90/141/187 andrack/test_metadata.rslines 45/80/125/166). Usingrollback()here clarifies that we're testing error detection without persisting test data.🔄 Suggested change
- txn.commit().await?; + txn.rollback().await?;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/api-db/src/machine_interface/test_duplicate_mac.rs` at line 73, Replace the `txn.commit().await?` call with `txn.rollback().await?` in the test_duplicate_mac test to maintain consistency with other tests in the codebase that also use rollback() when testing error handling paths. This clarifies that the test is validating error detection rather than the commit path, and ensures test data is not persisted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/api-db/src/machine_interface/test_duplicate_mac.rs`:
- Line 73: Replace the `txn.commit().await?` call with `txn.rollback().await?`
in the test_duplicate_mac test to maintain consistency with other tests in the
codebase that also use rollback() when testing error handling paths. This
clarifies that the test is validating error detection rather than the commit
path, and ensures test data is not persisted.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8c1df1a1-28b3-4970-8572-8c97fe9edf20
📒 Files selected for processing (17)
crates/api-core/src/tests/mod.rscrates/api-db/src/dns/domain.rscrates/api-db/src/dns/domain/test_create_domain.rscrates/api-db/src/lib.rscrates/api-db/src/machine_interface.rscrates/api-db/src/machine_interface/ip_allocator.rscrates/api-db/src/machine_interface/test_duplicate_mac.rscrates/api-db/src/machine_interface_address.rscrates/api-db/src/machine_interface_address/test_find_by_address.rscrates/api-db/src/power_shelf.rscrates/api-db/src/power_shelf/test_metadata.rscrates/api-db/src/rack.rscrates/api-db/src/rack/test_metadata.rscrates/api-db/src/switch.rscrates/api-db/src/switch/test_metadata.rscrates/api-db/src/test_support/mod.rscrates/api-db/src/test_support/network_segment.rs
💤 Files with no reviewable changes (1)
- crates/api-core/src/tests/mod.rs
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
Related issues
#2001
Type of Change
Breaking Changes
Testing
Additional Notes