Skip to content

test: carry validateFunc in every table - #100

Merged
retr0h merged 1 commit into
mainfrom
test/carry-validatefunc-in-tables
Sep 6, 2026
Merged

retr0h merged 1 commit into
mainfrom
test/carry-validatefunc-in-tables

Conversation

@retr0h

@retr0h retr0h commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

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 validateFunc callbacks. Eight of
the fourteen public test files had none at all, 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 that expectation eleven different ways —
expected, expectErr, expectRan, expectStatus, want, wantErr,
wantNil, wantLen, wantStatus, wantCapture, contains.

The mixed form also made the callback optional:

if tc.validateFunc != nil {
    tc.validateFunc(cmd)
}

TestDecode's case "Decodes nil data without error" supplied no callback, so
it checked only that Decode returned no error and never looked at the value it
decoded. Making the callback mandatory is what surfaced it. It now states what
it expects.

Two loops also decided things the case should own:
TestRunTaskStoresResultForAllPaths and TestHostResults computed a value and
asserted on it before handing what was left to the callback.

What changed

  • All 165 tables carry a mandatory validateFunc. None is optional.
  • The loop no longer decides anything: it makes the call and hands the results
    over. Error and success rows are the same shape.
  • The assertions inside the callbacks are the ones that were already in the loop
    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) and step_public_test.go (14) were uniform
    and converted mechanically; runner_public_test.go needed each of its seven
    tables done individually.
  • Selector columns that are genuine inputs, such as checkTask and
    lookupName, are kept — they say which thing to look at, not what to expect.

Verification

just go-vet reports 0 issues, just test passes, and coverage holds at exactly
100.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

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
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Thank you for contributing to this project! 😊🕹️

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00b29ac...24f1200. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@retr0h
retr0h merged commit 4ef6ba8 into main Sep 6, 2026
9 checks passed
@retr0h
retr0h deleted the test/carry-validatefunc-in-tables branch September 6, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant