Skip to content

test(http): split http_router_test.exs by concern#1082

Merged
andreasronge merged 1 commit into
mainfrom
claude/1076-split-http-router-test
Jun 3, 2026
Merged

test(http): split http_router_test.exs by concern#1082
andreasronge merged 1 commit into
mainfrom
claude/1076-split-http-router-test

Conversation

@andreasronge

Copy link
Copy Markdown
Owner

Summary

Splits the 902-line / 39-test mcp_server/test/ptc_runner_mcp/http_router_test.exs into five concern-scoped files under http/, with no test-logic changes (mechanical move):

New file Module Tests
http/router_auth_test.exs PtcRunnerMcp.Http.RouterAuthTest 401 challenge, health/ready, missing/bad auth, failed-auth rate limiting, rate-limit-disabled (11)
http/router_host_test.exs PtcRunnerMcp.Http.RouterHostTest hostile Host on GET/POST/DELETE (3)
http/router_origin_test.exs PtcRunnerMcp.Http.RouterOriginTest invalid/missing Origin handling (3)
http/router_dispatch_test.exs PtcRunnerMcp.Http.RouterDispatchTest 405/Allow, content-type, session init/exit/DELETE/drain/crash/permit lifecycle, owner indexing, protocol-version validation (19)
http/router_telemetry_test.exs PtcRunnerMcp.Http.RouterTelemetryTest request telemetry, log correlation, tool-call traces (3)

The shared ~20-line setup block plus the common conn helpers (auth/1, call/1, with_host/2, initialize_session/1) move into a new ExUnit.CaseTemplatePtcRunnerMcp.Http.RouterCase in test/support/http_router_case.ex — that each split file uses. Concern-specific helpers (bad_auth_post/1, attach_http_telemetry/0, start_ptc_sessions!/0, etc.) stay in their respective files. Every file remains async: false (global env + named registry). The original file is deleted.

Test plan

  • cd mcp_server && mix test test/ptc_runner_mcp/http/router_*_test.exs → 39 tests, 0 failures (same count as before)
  • mix precommit green (format, compile-as-errors, credo, dialyzer, full suite: 794 tests 0 failures)

Closes #1076

🤖 Generated with Claude Code

Splits the 902-line/39-test mcp_server/test/ptc_runner_mcp/http_router_test.exs
into five concern-scoped files under http/ (auth, host, origin, dispatch,
telemetry), all preserved verbatim. The shared ~20-line setup and conn helpers
move into a new ExUnit.CaseTemplate (PtcRunnerMcp.Http.RouterCase) that each
file uses, so there is no duplicated setup. Every file stays async: false.

Verified: cd mcp_server && mix test runs 39 router tests, 0 failures; mix
precommit green.

Closes #1076

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

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

PR Review: test(http): split http_router_test.exs by concern

Summary

Splits the 902-line / 39-test http_router_test.exs into five concern-scoped files under http/ (router_auth, router_host, router_origin, router_dispatch, router_telemetry), extracting the shared setup and conn helpers into a new ExUnit.CaseTemplate (PtcRunnerMcp.Http.RouterCase). Clean, well-scoped mechanical refactor that closely matches the spec in #1076.

What's Good

  • Faithful to the issue spec: file paths (http/router_*_test.exs), module names (PtcRunnerMcp.Http.Router*Test), the router_ prefix to avoid colliding with existing http/host_test.exs/origin_test.exs unit tests, and the test-to-file mapping all match [From PR #1075] Split http_router_test.exs by concern #1076 exactly.
  • Shared setup is genuinely deduplicated: the ~20-line setup, @token, auth/1, call/1, with_host/2, and initialize_session/1 live once in RouterCase. No copy-pasted setup blocks across files — exactly the drift the issue warned against.
  • Concern-specific helpers stay local with no cross-file duplication: bad_auth_post/valid_initialize/with_remote_ip (auth), start_ptc_sessions!/long_running_program (dispatch), attach_http_telemetry/read_jsonl (telemetry).
  • Constraints honored: every file is async: false (via use RouterCase), all are well under the 800-line threshold (158/40/46/451/159), the original file is deleted, and the RouterCase moduledoc documents the async: false rationale and references [From PR #1075] Split http_router_test.exs by concern #1076.

Verification performed

  • Test count preserved: 11 + 3 + 3 + 19 + 3 = 39 (matches pre-split).
  • mix test test/ptc_runner_mcp/http/router_*_test.exs39 tests, 0 failures.
  • mix format --check-formatted on all new files → clean.
  • Diff is purely additive/deletive (967 added / 902 deleted, original removed); no docs/specs/*.md modified; no new TODO/FIXME/@tag :skip/credo:disable.

Issues (Must Fix)

None.

Suggestions (Optional)

None — the split is tidy and the helper placement is sensible.

Security

No concerns. Test-only change; no production code touched.

Documentation

No updates needed. This is a test reorganization with no public API or behavior change. The RouterCase moduledoc adequately documents the template's purpose and the async: false constraint.

Verdict

Approve. Mechanical, spec-conformant split with proper deduplication via ExUnit.CaseTemplate, preserved test count, and a green local test + format run.

@claude claude Bot added the ready-to-merge PR is ready to be merged label Jun 3, 2026
@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Auto-Triage Summary

Issue Decision Action
(none) No issues found in review

Review verdict: Approve — mechanical, spec-conformant split with no must-fix or optional items raised. Labelled .

@andreasronge andreasronge enabled auto-merge (squash) June 3, 2026 10:57
@andreasronge andreasronge merged commit c953697 into main Jun 3, 2026
10 checks passed
@andreasronge andreasronge deleted the claude/1076-split-http-router-test branch June 3, 2026 10:57
andreasronge added a commit that referenced this pull request Jun 4, 2026
Splits the 902-line/39-test mcp_server/test/ptc_runner_mcp/http_router_test.exs
into five concern-scoped files under http/ (auth, host, origin, dispatch,
telemetry), all preserved verbatim. The shared ~20-line setup and conn helpers
move into a new ExUnit.CaseTemplate (PtcRunnerMcp.Http.RouterCase) that each
file uses, so there is no duplicated setup. Every file stays async: false.

Verified: cd mcp_server && mix test runs 39 router tests, 0 failures; mix
precommit green.

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

Labels

ready-to-merge PR is ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[From PR #1075] Split http_router_test.exs by concern

1 participant