Add route_request dispatch coverage#689
Conversation
prk-Jr
left a comment
There was a problem hiding this comment.
Summary
This PR adds focused Fastly adapter coverage for route_request. The overall direction is useful, but one assertion currently does not prove the route branch it is intended to cover because another branch can produce the same failure status.
CI Status
- cargo fmt: PASS
- cargo test: PASS
- vitest: PASS
- integration tests: PASS
- browser integration tests: PASS
- CodeQL: PASS
- analysis jobs: PASS
|
|
||
| let resp = route_with_settings(&settings, req).expect("should route auction request"); | ||
|
|
||
| assert_eq!( |
There was a problem hiding this comment.
🔧 wrench — Auction route test can pass through the fallback path
auction_route_dispatches_to_consent_dependent_path asserts 503 with a missing consent store. That does not prove /auction dispatched to handle_auction, because the unknown-route publisher fallback also calls runtime_services_for_consent_route first and would return the same 503 if the /auction matcher were removed or typoed.
Fix: use a route-specific auction failure that fallback would not produce, for example settings without a consent store plus an invalid banner size:
let settings = create_test_settings_without_consent_store();
let req = Request::post("https://test.com/auction").with_body(
r#"{"adUnits":[{"code":"slot","mediaTypes":{"banner":{"sizes":[[300]]}},"bids":[]}],"config":null}"#,
);
let mut resp = route_with_settings(&settings, req).expect("should route auction request");
assert_eq!(resp.get_status(), StatusCode::BAD_REQUEST);
assert!(resp.take_body_str().contains("Invalid banner size"));|
|
||
| #[test] | ||
| fn unknown_route_falls_back_to_publisher_proxy_path() { | ||
| let settings = create_test_settings_without_consent_store(); |
There was a problem hiding this comment.
🤔 thinking — Publisher fallback test depends on ambient DNS failure
unknown_route_falls_back_to_publisher_proxy_path gets 502 because the configured origin cannot be resolved; the local run emitted a Viceroy DNS error. To make the failure mode intentional, consider a fallback-specific settings helper with an RFC-reserved .invalid origin host.
| } | ||
|
|
||
| #[test] | ||
| fn static_tsjs_route_serves_unified_bundle() { |
There was a problem hiding this comment.
🌱 seedling — Static route coverage misses deferred module success
The static route tests cover unified bundle success and unknown bundle failure. Since this config enables Prebid, adding /static/tsjs=tsjs-prebid.min.js would also cover the deferred-module branch in handle_tsjs_dynamic.
Summary
route_requestdispatch coverage.Closes #451
Tests
cargo test -p trusted-server-adapter-fastly route_tests -- --nocapturecargo fmt --all -- --checkcargo test --workspacecargo clippy --workspace --all-targets --all-features -- -D warnings