Add error status code mapping tests - #755
Merged
Merged
Conversation
aram356
requested review from
aram356 and
prk-Jr
and removed request for
aram356
June 15, 2026 15:47
aram356
approved these changes
Jun 16, 2026
aram356
left a comment
Collaborator
There was a problem hiding this comment.
Summary
Clean, well-scoped test-only change. Adds status_code_returns_expected_http_status_for_each_variant, a table-driven test that locks the TrustedServerError::status_code() → HTTP-status contract. Verified all 17 enum variants are exercised and every expected status matches the implementation exactly. Closes #448.
Verdict: APPROVE.
Non-blocking
🌱 seedling
- Exhaustiveness isn't compile-enforced — The new
casesarray is hand-maintained, so a future 18th variant would compile and pass without being covered here (it would simply go untested). The practical risk is low:status_code()'smatchhas no_arm, so a new variant always forces an explicit mapping decision in production code — only its test coverage could be forgotten, not its handling. Flagging for awareness; no change requested. Driving the expected value through a second exhaustivematchin the test would mostly duplicate the productionmatchfor little added assurance, so I'd lean against it.
👍 praise
- Complete and accurate coverage — all 17 variants present, each mapped to the correct status; complements the existing
user_message()tests without overlap. Follows conventions:"should ..."assertion messages,String::from(...), fictionalexample.comdata only.
CI Status
- cargo test: PASS (required)
- cargo fmt: PASS (required)
- format-typescript: PASS (required)
- format-docs: PASS (required)
- vitest: PASS
- Analyze (rust): PASS
- Analyze (javascript-typescript): PASS
- Analyze (actions): PASS
- CodeQL: PASS
- integration tests: PASS
- browser integration tests: PASS
- prepare integration artifacts: PASS
Test passes locally in an isolated worktree at head c65c2a0 (cargo test -p trusted-server-core error::tests → 3 passed).
aram356
reviewed
Jun 16, 2026
aram356
left a comment
Collaborator
There was a problem hiding this comment.
Follow-up to my approval: one optional inline suggestion to make the variant coverage compile-enforced. The PR is already approved — this is a non-blocking ♻️ refactor you can one-click apply or skip.
prk-Jr
approved these changes
Jun 16, 2026
Co-authored-by: Aram Grigoryan <132480+aram356@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TrustedServerError::status_code().Changes
crates/trusted-server-core/src/error.rsTrustedServerErrorvariants.Closes
Closes #448
Test plan
cargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkcd crates/js/lib && npx vitest runcd crates/js/lib && npm run formatcd docs && npm run formatcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute servecargo test -p trusted-server-core error::tests;cargo test -p trusted-server-coreChecklist
unwrap()in production code — useexpect("should ...")tracingmacros (notprintln!)