docs: state the mocking convention - #453
Merged
Merged
Conversation
repo-standards requires a repository to state in full the conventions it is held to. The mocking rule was in the corpus and in no repository, so a contributor reading this guide could not learn it here. Adds Test doubles to the shared Code standards section: a double for an interface we define is generated with mockgen, generated mocks live in a mocks package beside the code they mock, the generator resolves through the module tool dependencies, and gen is reserved for API code generation. Three doubles stay hand-written, where generating buys nothing. Stated identically in all five Go repositories. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Test doubles section under Code standards and the Test file conventions list under Testing both said mocks are generated and never hand-written. repo-standards requires a fact to be stated in exactly one file; stating it twice in one file is the same defect. Test doubles owns it, since that is where the layout, the generator directive, and the exceptions are. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #453 +/- ##
=======================================
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.
States the mocking convention in this repository, as
repo-standardsrequires: a repository states in full the conventions it is held to, and the rule was in the corpus and in no repository.Implements
rescope-go-code-standardstask 5.4. The rule itself landed in osapi-io/specs#96.What the section says
mockgenand committed. Do not hand-write a struct to satisfy one.mockspackage beside the code they mock, produced by agenerate.goholding the//go:generatedirective.go.modrecords.gen/is reserved for API code generation — mocks do not go there.Three doubles stay hand-written, because generating them buys nothing: stdlib interfaces, doubles carrying a real implementation, and recorders for a dependency called from a goroutine the test cannot join.
Identical in all five
The shared
Code standardsblock hashes the same ingohai,nats-client,nats-server,osapi-orchestrator, andosapi— so a difference in wording would mean a difference in rule.Docs only.
just md-fmt-checkpasses.Next: the implementations get fixed —
gohai's fourCollectordoubles andinternal/executor/gen/, andosapi-orchestrator'smockRenderer.🤖 Generated with Claude Code