refactor: extract resolve_coalesced, test real code #21

Merged
razvandimescu merged 2 commits from refactor/extract-resolve-coalesced into main 2026-03-29 16:14:25 +08:00
razvandimescu commented 2026-03-29 15:56:19 +08:00 (Migrated from github.com)

Summary

  • Extract Disposition, acquire_inflight(), and resolve_coalesced() from handle_query so coalescing logic is independently testable
  • handle_query now delegates to resolve_coalesced with resolve_recursive as the closure
  • Rewrite 4 integration tests to call resolve_coalesced directly with mock futures — no TCP servers, no iterative resolver chain, deterministic
  • Add Debug derive to QueryPath for assert_eq! in tests
  • Fix: SERVFAIL responses now use response_from to echo the question section (RFC compliance)
  • Fix: Error messages preserved via Option<String> return — caller logs actual error instead of generic "RECURSIVE ERROR"
  • New tests: servfail_leader_includes_question_section, leader_error_preserves_message, follower SERVFAIL question-section assertions

Test plan

  • 14 coalescing tests: InflightGuard (3), acquire_inflight (5), resolve_coalesced integration (6)
  • All tests call production code, not tokio primitives
  • make all passes (fmt, clippy, audit, build, 111 tests)

🤖 Generated with Claude Code

## Summary - Extract `Disposition`, `acquire_inflight()`, and `resolve_coalesced()` from `handle_query` so coalescing logic is independently testable - `handle_query` now delegates to `resolve_coalesced` with `resolve_recursive` as the closure - Rewrite 4 integration tests to call `resolve_coalesced` directly with mock futures — no TCP servers, no iterative resolver chain, deterministic - Add `Debug` derive to `QueryPath` for `assert_eq!` in tests - **Fix**: SERVFAIL responses now use `response_from` to echo the question section (RFC compliance) - **Fix**: Error messages preserved via `Option<String>` return — caller logs actual error instead of generic "RECURSIVE ERROR" - New tests: `servfail_leader_includes_question_section`, `leader_error_preserves_message`, follower SERVFAIL question-section assertions ## Test plan - [x] 14 coalescing tests: InflightGuard (3), acquire_inflight (5), resolve_coalesced integration (6) - [x] All tests call production code, not tokio primitives - [x] `make all` passes (fmt, clippy, audit, build, 111 tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.