feat: add comprehensive test suite for ExploreDNS
CI / test (pull_request) Failing after 2m36s

- Unit tests for all internal packages exceeding 80% coverage:
  - internal/config: 86.2% (ParseMaxDepth, ParseRetries, validation paths)
  - internal/dns: 82.9% (IterativeQueryWithExchange, mock DNS server, roots)
  - internal/fingerprint: 96.4% (unchanged, already excellent)
  - internal/output: 86.7% (formatters, stats, JSON/text output, hooks)
  - internal/traverse: 86.7% (SetHooks, ResolveNS, processReferral,
    ensureRDFalse, resolveGlueViaSystem, newAQuery, Referral.Resolve)

- Integration tests in internal/integration/:
  - End-to-end traversal with mock DNS exchange function
  - Referral chain traversal (root -> TLD -> authoritative)
  - CNAME resolution and loop detection
  - NXDOMAIN and SERVFAIL response handling
  - Max depth enforcement
  - Context cancellation
  - TraverserHooks event delivery

- Mock DNS server helper in internal/dns/roots_test.go using miekg/dns
  (enables deterministic testing without network dependency)

- CI updated with coverage reporting step
- Makefile: added 'cover' target for local HTML coverage reports

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
Gary Hansen
2026-06-08 03:47:04 +10:00
co-authored by Copilot multica-agent
parent fe1afe2a97
commit 5d1e5ca86c
11 changed files with 2590 additions and 2 deletions
+19
View File
@@ -455,3 +455,22 @@ func TestBasicResolver(t *testing.T) {
t.Fatal("BasicResolver does not implement Resolver interface")
}
}
// TestBasicResolverQueryIntegration calls Query via the BasicResolver against
// the local system resolver. Skipped when no local resolver is reachable.
func TestBasicResolverQueryIntegration(t *testing.T) {
r := NewBasicResolver()
server := net.ParseIP("127.0.0.1")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// Cover BasicResolver.Query; skip if 127.0.0.1:53 is not available.
msg, err := r.Query(ctx, server, ".", TypeNS, nil)
if err != nil {
t.Logf("skipping (local resolver unavailable): %v", err)
t.Skip()
}
if msg == nil {
t.Fatal("expected non-nil response from BasicResolver.Query")
}
}