test: carry validateFunc in every table - #100
Merged
Merged
Conversation
CONTRIBUTING says external test tables carry validateFunc callbacks.
Eight of fourteen files had none, and four more mixed the two styles:
a validateFunc for the success path while the loop still branched on an
expectation field for the error path. Across the repository 165 tables
named their expectation eleven different ways, among them expected,
expectErr, expectRan, want, wantNil, wantLen and checkTask.
The mixed form also made the callback optional. A table wrote
if tc.validateFunc != nil {
tc.validateFunc(cmd)
}
so a case that supplied none asserted nothing and still passed. TestDecode
had exactly one such case, "Decodes nil data without error", which
checked no result at all. It now states what it expects.
Every table carries a mandatory validateFunc, and the loop no longer
decides anything: it makes the call and hands the results over.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CM5qrNtYQvdKcemkS5YpiP
|
Thank you for contributing to this project! 😊🕹️ |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #100 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 2866 2866
=========================================
Hits 2866 2866 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.
An audit against CONTRIBUTING.md, matching the
ones done in nats-client#152
and nats-server#118. Test
files only; no production code changes.
What was wrong
CONTRIBUTING says external test tables carry
validateFunccallbacks. Eight ofthe fourteen public test files had none at all, and four more mixed the two
styles: a
validateFuncfor the success path while the loop still branched onan expectation field for the error path.
Across the repository, 165 tables named that expectation eleven different ways —
expected,expectErr,expectRan,expectStatus,want,wantErr,wantNil,wantLen,wantStatus,wantCapture,contains.The mixed form also made the callback optional:
TestDecode's case"Decodes nil data without error"supplied no callback, soit checked only that
Decodereturned no error and never looked at the value itdecoded. Making the callback mandatory is what surfaced it. It now states what
it expects.
Two loops also decided things the case should own:
TestRunTaskStoresResultForAllPathsandTestHostResultscomputed a value andasserted on it before handing what was left to the callback.
What changed
validateFunc. None is optional.over. Error and success rows are the same shape.
bodies, moved to the case that owns them. The one exception is the case above,
which gained an assertion it did not have.
ops_public_test.go(101 tables) andstep_public_test.go(14) were uniformand converted mechanically;
runner_public_test.goneeded each of its seventables done individually.
checkTaskandlookupName, are kept — they say which thing to look at, not what to expect.Verification
just go-vetreports 0 issues,just testpasses, and coverage holds at exactly100.0%.
Related
The same sentence was missing from OSAPI's CONTRIBUTING even though it is the
heaviest user of the convention; added in
osapi#484. gohai neither documents
nor follows it and is tracked separately.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CM5qrNtYQvdKcemkS5YpiP