Skip to content

UTS: migrate rest/unit mock HTTP to the handler idiom and fix /time response shape - #534

Open
owenpearson wants to merge 1 commit into
mainfrom
fix/uts-mock-http-migration
Open

owenpearson wants to merge 1 commit into
mainfrom
fix/uts-mock-http-migration

Conversation

@owenpearson

@owenpearson owenpearson commented Sep 21, 2026

Copy link
Copy Markdown
Member

Fixes two coupled UTS test-spec defects in uts/rest/unit/, reported as #523 and #524.

#523 — migrate the queue-based mock idiom to the handler idiom

Replaces every use of the undefined/banned queue API (queue_response, queue_responses, queue_response_for_host, queue_response_for_url, queue_timeout, queue_delayed_response, and mock_http.captured_requests) with the onRequest/onConnectionAttempt handler idiom plus a LOCAL captured_requests array (with local request_count/captured_hosts where needed), matching the contract in helpers/mock_http.md and the already-migrated blocks in fallback.md. In the same pass:

  • Error-body fixtures repaired to the full { "error": { "message", "code", "statusCode" } } shape, including the CloudFront fixture whose error was a bare string.
  • The two pinned-fallback-host tests (RSC15f/successful-fallback-cached-0, RSC15f/cached-fallback-expires-1) now dispatch on req.url.host and bind assertions to the observed fallback host rather than a hard-coded name, resolving the 1/5-flaky pin against RSC15a's random ordering.
  • Mock-contract cross-references retargeted from rest_client.md to helpers/mock_http.md at fallback.md:10 and request.md:10,16; dropped the fallback.md:12-15 block requesting capabilities the contract deliberately omits.

#524 — fix the /time response shape

/time returns a single-element ARRAY [server_time_ms], not {"time": N}. Corrected at every site, contract file first (helpers/mock_http.md, then writing-test-specs.md, then the specs), including rest_client.md's msgpack site which becomes msgpack_encode([1234567890000]). Migrated handlers from #523 emit the array shape so the two fixes converge; no object-shaped /time fixture remains anywhere under uts/.

Files changed

  • uts/rest/unit/fallback.md — full migration + error-body repair + host-pin fix + array shape (+707/-… lines)
  • uts/rest/unit/request.md — RSC19d/HP + RSC19b/c/e/f migration, array shape, non-array redirect
  • uts/rest/unit/rest_client.md — 12 queue sites + msgpack /time + array shape
  • uts/rest/unit/request_endpoint.md — local captured_requests + array shape
  • uts/rest/unit/helpers/mock_http.md — 4 /time sites
  • uts/rest/unit/auth/authorize.md — 1 /time site
  • uts/docs/writing-test-specs.md — 3 /time sites in the authoring guide

Judgment calls

Merge order

This is PR 1 of 7 and should merge FIRST. It conflicts with the spec-point-references PR on auth/authorize.md and with the housekeeping PR on fallback.md/rest_client.md.

No features.md change is required or made.

Closes #523
Closes #524

🤖 Generated with Claude Code

…esponse shape

Migrates fallback.md, request.md, rest_client.md and request_endpoint.md off the
undefined queue-based mock API onto the onRequest/onConnectionAttempt handler idiom
with local captured_requests, repairs error-body fixtures to the full
message/code/statusCode shape, and corrects the /time mock body from {"time": N} to
the array [N] throughout.

Closes #523
Closes #524

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
staging/pull/534 397a023b Deployed Sep 21, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment