fix: mock DNS client in resolver tests (replaces PR #25) #27

Closed
clawbot wants to merge 1 commits from fix/mock-resolver-tests into main
Collaborator

Problem

Resolver tests did real iterative DNS lookups from root nameservers, causing make check to hang/take >30s.

PR #25 tried to fix this by adding -short to skip tests — that's wrong (same as weakening linter config).

Solution

Mock the DNSClient interface in tests using canned responses. Uses the existing NewFromLoggerWithClient constructor — no production code changes.

  • All 29 resolver tests pass in ~1s with zero network calls
  • make check passes with 0 issues
  • No -short flags, no skipped tests, no Makefile changes

make check output

==> Checking formatting...
==> Running linter...
0 issues.
==> Running tests...
ok  sneak.berlin/go/dnswatcher/internal/resolver  1.192s
==> All checks passed!

Closes #25 approach — this is the correct fix.

## Problem Resolver tests did real iterative DNS lookups from root nameservers, causing `make check` to hang/take >30s. PR #25 tried to fix this by adding `-short` to skip tests — that's wrong (same as weakening linter config). ## Solution Mock the `DNSClient` interface in tests using canned responses. Uses the existing `NewFromLoggerWithClient` constructor — no production code changes. - All 29 resolver tests pass in ~1s with zero network calls - `make check` passes with 0 issues - No `-short` flags, no skipped tests, no Makefile changes ## `make check` output ``` ==> Checking formatting... ==> Running linter... 0 issues. ==> Running tests... ok sneak.berlin/go/dnswatcher/internal/resolver 1.192s ==> All checks passed! ``` Closes #25 approach — this is the correct fix.
sneak was assigned by clawbot 2026-02-21 11:57:36 +01:00
clawbot added 1 commit 2026-02-21 11:57:37 +01:00
fix: mock DNS client in resolver tests to avoid network calls
All checks were successful
Check / check (pull_request) Successful in 10m10s
9b93385f6f
Replace real DNS lookups in resolver_test.go with a mock DNSClient
that returns canned responses. Tests now run in ~1s instead of >30s
with no network dependency.

Uses the existing NewFromLoggerWithClient constructor and DNSClient
interface — no production code changes needed.
clawbot closed this pull request 2026-02-21 11:58:05 +01:00
Some checks are pending
Check / check (pull_request) Successful in 10m10s
check / check (push)
Required

Pull request closed

Sign in to join this conversation.