fix: constrain what a test does, not how a symbol is exposed - #80
Merged
Conversation
The requirement banned exposing an alias to an unexported function from export_test.go. That is an idiomatic Go pattern; twenty-two standard library packages use it, net/http most heavily. The concern it came from is real but is about the test, not the mechanism: an alias should not be used to re-cover behavior the caller's own test already reaches. The requirement now says that, and a scenario allows the case the pattern exists for. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thank you for contributing to this project! 😊🕹️ |
This was referenced Aug 16, 2026
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.
Applying
specify-go-code-standardsshowed this requirement is wrong. Correcting it on its own, before any code, per CONTRIBUTING.What was wrong
The requirement said
export_test.go"SHALL NOT expose an alias to an unexported function", permitting only setter functions.That outlaws an idiomatic Go pattern. Twenty-two standard library packages use it.
net/http/export_test.goalone:Verification 3.5 found ten such aliases across
gohaiandosapi, with eleven call sites. I reported that as debt to pay down. It was not — the rule was wrong.Where the rule came from, and what it was actually protecting
gohaiwrote it after aliases produced tests that re-covered paths the caller's own test already exercised. That concern is real. But it is a concern about what the test does, not about how the symbol was exposed. Banning the mechanism outlawed an idiom in order to prevent one misuse of it.The corrected requirement
Names the misuse instead: a test SHALL NOT use an exported alias to re-cover behavior the caller's test already reaches. Seams still belong at the boundary with a dependency rather than partway through the code under test — that part was always about test design and is unchanged.
A third scenario now covers the case the pattern exists for: a pure helper with its own contract, independent of its callers —
BytesToString,ParseOffset— is exactly what should be exposed and tested directly.Task 3.5 is rewritten to check the behavior rather than the mechanism. No code changes; the ten aliases stay.
Alternative considered and rejected: keep the ban and remove the aliases — rewriting eleven working call sites to satisfy a rule the language's own standard library does not follow.
🤖 Generated with Claude Code