Skip to content

Commit 0b8770e

Browse files
authored
test(network): fold onto carbide-test-support + enumerate cases to raise coverage (#2538)
## Description The `network` crate tests for MAC formatting, IP prefixes, prefix sets, address families, and VPC virtualization were comprised of number of various assertions. This folds them onto `carbide-test-support` based `Case`/`Check` tables and then enumerates the input variants each pure function accepts and rejects every separator and boundary length for MAC parsing, both Ok and Err arms for prefix and family conversions, membership and aggregation edges for IpSet, and every enum variant for the virtualization helpers. The dense per-row enumeration is what moves the numbers. Enumerating the prefix surface also surfaced a real bug: Ipv6 bifurcate built its midpoint bit mask from a 64-bit literal (0x8000_0000_0000_0000), so for a v6 prefix it flipped a bit 64 positions too low and returned the wrong sibling (2001:db8::8000:0/33 instead of 2001:db8:8000::/33). Widening the literal to the full 128-bit top bit fixes it; the v4 path was already correct. - `base_mac` / lib: enumerated MAC parse/format/serde over separators, boundary lengths, and the sanitize-and-rewrite path. - `ip`: enumerated prefix from_str/TryFrom/contains/Ord/bifurcate/aggregate and the address-family helpers; fixed the v6 bifurcate sibling bug above. - `virtualization`: enumerated the FNN/L2 SVI and dual-stack helpers across every variant, and round-tripped the sqlx `Encode`/`Decode` impls through a real Postgres connection with `check_cases_async` and the shared `sqlx_test` harness. ``` ┌──────────┬─────────┬─────────┐ │ Metric │ Before │ After │ ├──────────┼─────────┼─────────┤ │ Region │ 78.78% │ 93.91% │ │ Function │ 71.78% │ 93.10% │ │ Line │ 73.64% │ 96.82% │ └──────────┴─────────┴─────────┘ ``` The sqlx `Encode`/`Decode` impls are now exercised by a real Postgres round-trip — `carbide-test-support`'s async runner driving the shared `sqlx_test` harness — so the table-driven approach reaches the database codec too. What's left is mostly defensive match arms. All tests pass and clippy is clean. Signed-off-by: Chet Nichols III <chetn@nvidia.com> ## Type of Change <!-- Check one that best describes this PR --> - [ ] **Add** - New feature or capability - [ ] **Change** - Changes in existing functionality - [ ] **Fix** - Bug fixes - [ ] **Remove** - Removed features or deprecated functionality - [x] **Internal** - Internal changes (refactoring, tests, docs, etc.) ## Related Issues (Optional) <!-- If applicable, provide GitHub Issue. --> ## Breaking Changes - [ ] This PR contains breaking changes <!-- If checked above, describe the breaking changes and migration steps --> ## Testing <!-- How was this tested? Check all that apply --> - [x] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [ ] No testing required (docs, internal refactor, etc.) ## Additional Notes <!-- Any additional context, deployment notes, or reviewer guidance --> Signed-off-by: Chet Nichols III <chetn@nvidia.com>
1 parent 794eea3 commit 0b8770e

7 files changed

Lines changed: 2421 additions & 320 deletions

File tree

crates/network/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ sqlx = { workspace = true, features = [
5050
thiserror = { workspace = true }
5151

5252
[dev-dependencies]
53+
carbide-test-support = { path = "../test-support" }
54+
carbide-macros = { path = "../macros" }
55+
carbide-sqlx-testing = { path = "../sqlx-testing", default-features = false }
5356
serde_json = { workspace = true }
57+
sqlx = { workspace = true, features = ["runtime-tokio", "tls-rustls", "postgres"] }
5458

5559
[lints]
5660
workspace = true

0 commit comments

Comments
 (0)