Skip to content

Add test coverage for error mapping and tsjs helpers#648

Open
ChristianPavilonis wants to merge 1 commit intomainfrom
tests/improve-test-covereage
Open

Add test coverage for error mapping and tsjs helpers#648
ChristianPavilonis wants to merge 1 commit intomainfrom
tests/improve-test-covereage

Conversation

@ChristianPavilonis
Copy link
Copy Markdown
Collaborator

Summary

  • add exhaustive unit coverage for TrustedServerError::status_code() so each public variant is pinned to its expected HTTP response
  • add direct tsjs formatting tests for unified and deferred script URL/tag helpers using computed hashes
  • cover invalid UTF-8 cookie-header handling and simplify duplicate callback serde rename tests

Changes

File Change
crates/trusted-server-core/src/error.rs Added a table-driven test covering HTTP status code mapping for every TrustedServerError variant.
crates/trusted-server-core/src/tsjs.rs Added direct unit tests for unified and deferred TS/JS script URL and tag helpers.
crates/trusted-server-core/src/cookies.rs Added a unit test for invalid UTF-8 Cookie header handling in handle_request_cookies().
crates/trusted-server-core/src/models.rs Consolidated duplicate callback serde rename tests into one focused test.

Closes

Closes #448
Closes #450
Closes #454
Closes #456

Test plan

  • cargo test --workspace
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check
  • JS tests: cd crates/js/lib && npx vitest run
  • JS format: cd crates/js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other:

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant