Skip to content

Fix test suite by injecting time dependency for RRSIG validation#13

Merged
peterzen merged 5 commits intomasterfrom
copilot/fix-test-suite-issues
Feb 16, 2026
Merged

Fix test suite by injecting time dependency for RRSIG validation#13
peterzen merged 5 commits intomasterfrom
copilot/fix-test-suite-issues

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

Test suite failing because RRSIG records in test data (from 2019) are validated against current time. All signatures expired years ago, causing 6 test failures.

Changes

Time injection in Resolver

  • Added timeNow func() time.Time field to Resolver, defaults to time.Now
  • Enables time mocking in tests while preserving production behavior

Updated RRSIG validation

  • SignedZone now holds resolver reference to access time function
  • verifyRRSIG() uses z.resolver.timeNow() instead of time.Now()
  • Made newSignedZone() internal to avoid API surface change

Test updates

  • Mock time set to March 7, 2019 12:00 UTC in newResolver() test helper
  • Date falls within all test data RRSIG validity periods (inception: Mar 5, expiration: Mar 10+)
// Production: uses real time
resolver, _ := NewResolver("/etc/resolv.conf")

// Tests: inject fixed time
resolver.timeNow = func() time.Time {
    return time.Date(2019, 3, 7, 12, 0, 0, 0, time.UTC)
}

Impact

  • Fixes all 6 failing tests without regenerating test data
  • No breaking changes to public API
  • Coverage unchanged at 77.7%
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix test suite</issue_title>
<issue_description>Analyze the failing test cases and suggest a strategy to fix them.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 16, 2026 01:05
Co-authored-by: peterzen <5878500+peterzen@users.noreply.github.com>
Co-authored-by: peterzen <5878500+peterzen@users.noreply.github.com>
Co-authored-by: peterzen <5878500+peterzen@users.noreply.github.com>
Co-authored-by: peterzen <5878500+peterzen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing test cases in test suite Fix test suite by injecting time dependency for RRSIG validation Feb 16, 2026
Copilot AI requested a review from peterzen February 16, 2026 01:11
@peterzen peterzen marked this pull request as ready for review February 16, 2026 13:02
@peterzen peterzen merged commit 541ad1d into master Feb 16, 2026
1 check passed
@peterzen peterzen deleted the copilot/fix-test-suite-issues branch February 16, 2026 13:09
This was referenced Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix test suite

2 participants