test: generate the audit store and PKI signer doubles - #455
Merged
Conversation
Both were hand-written for interfaces this repository defines, and both had been recorded as relying on an exception. Neither needed one. captureStore stood in for a write the audit middleware dispatches from a goroutine it does not join. That is real, but the test coped with it by sleeping fifty milliseconds, seven times. The generated mock closes a channel from its write handler, so the test waits on the call rather than on a duration. A generated MockStore already existed beside it. mockPKISigner was kept because the test verifies a real ed25519 signature, which a scripted double would make vacuous. A generated mock delegates to ed25519.Sign from its return handler, so the signature stays real and the assertion keeps its meaning. Paths that skip auditing now assert Times(0) rather than sleeping and finding nothing, so a regression that starts auditing an excluded path fails instead of passing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #455 +/- ##
=======================================
Coverage 99.94% 99.94%
=======================================
Files 484 484
Lines 24935 24935
=======================================
Hits 24921 24921
Misses 14 14 Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
rescope-go-code-standardstasks 5.8 and 5.8a. Both doubles were hand-written for interfaces this repository defines, and both had been recorded as relying on an exception. Neither needed one.captureStore→ generatedMockStoreThe exception it claimed was real — the middleware writes from a bare
go func()nothing can join. But the test coped with that by sleeping:A generated mock can create the join point the test lacked:
Seven sleeps removed. The test now waits on the call itself, not on a guess that can be wrong on a loaded runner.
A generated
MockStorealready existed ininternal/audit/mocks/— the hand-written spy was sitting next to it.The excluded paths got a real assertion
Previously they slept and then checked nothing had been written. Now:
The middleware returns before spawning the goroutine for excluded and unauthenticated paths, so nothing is racing. A regression that starts auditing
/metricsnow fails instead of passing because the sleep was long enough to see nothing.mockPKISigner→ generatedMockPKISignerThis was kept on the grounds that the test verifies a real signature:
True, and irrelevant — a generated mock delegates to the real implementation:
Two constructors, per the "constructor returning a configured mock" guidance, since twelve call sites needed the pair and some need the controller key reported as their own.
Verification
just test— passes, coverage 100% against a 99.9% gate. No hand-written double remains for an interface this repository defines.🤖 Generated with Claude Code