Skip to content

test(antvet): hold the API to the tables that judge its pointers - #358

Open
lx3133584 wants to merge 1 commit into
skudra-go:mainfrom
lx3133584:test/antvet-api-table-guard
Open

lx3133584 wants to merge 1 commit into
skudra-go:mainfrom
lx3133584:test/antvet-api-table-guard

Conversation

@lx3133584

Copy link
Copy Markdown
Contributor

Fixes #102, or rather the part of it left: the table entries are in since #291, so what remains is the guard from the fix idea, and a test now holds an API to a table entry instead of leaving it to a call that fails at run time.

TestTablesCoverAPI walks docs/api.txt, the generated list of the package's API, and fails when an exported function or method takes a field pointer (*V ...*V) or a relation pointer (*[]R, *[]T, **R, **T, **C) and is in no table. Names are told apart by receiver, so Query.Latest is not taken for a function Latest. A function whose entry in fieldFuncs goes missing still fails even though the analyzer knows it from aggregates, because the aggregate path reads the field from where fieldFuncs puts it.

Methods of receivers antvet does not follow are left out: a ModelBuilder's are judged by the key and relation rules where a model's Configure is read, and an Expr or Window names no model a call could disagree with. The few functions that take a pointer on purpose without being judged (Coalesce, Lag, DatePart and the like) are listed in the test, so a new one still has to be seen.

Removing Latest, Oldest, Load or RecursiveOne from the tables, or an entry from fieldFuncs, fails the test; adding them back passes it.

go vet ./... and go test ./... pass under tools/antvet.

TestTablesCoverAPI walks docs/api.txt, the generated list of the package's
API, and fails when an exported function or method takes a field pointer, or
a relation pointer, and is in none of the tables. An API added without an
entry is caught here rather than at run time, where only the call that misses
a probe reports ErrNotProbe, and only if it is reached.

Names are matched by receiver, so a Query and a Join method are told apart
from the function of the same name. Methods of a receiver antvet does not
follow are left out: a ModelBuilder's are judged by the key and relation
rules where Configure is read, and an Expr or Window names no model a call
could disagree with. The few functions that take a pointer unjudged are
listed in the test.

A function in aggregates is still held to its fieldFuncs entry: the aggregate
path reads its field from where fieldFuncs puts it, so a missing entry there
loses the check even though the function is known.
@lx3133584
lx3133584 force-pushed the test/antvet-api-table-guard branch from cb568a5 to b43f45b Compare December 1, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

antvet misses non-probe pointers in Latest, Oldest, Load, LoadOne, LoadMissing and Recursive

1 participant