| id | 2606240211 |
|---|---|
| title | Add dedicated unit tests for locate.go helpers |
| status | ✅ |
| model | sonnet |
| summary | internal/index/locate.go has 12 unexported helpers without dedicated unit tests. Add a named test for each so the audit policy is satisfied. |
Add a named unit test for each of the 12 unexported
helpers in internal/index/locate.go. The 2026-06-24
audit requires it.
Go arch doc §"Tests" requires every production function to have a dedicated test by name. The 2026-06-24 audit (range: 1599c9f..09f22d3) flagged this file.
Functions without a dedicated test as of 09f22d3:
headingInfo— extract text, level, anchor from a heading nodelocateInAST— walk AST at a line/col offsetlinkContainsOffset— byte offset inside a linklinkCloseOffset— find closing bracket offsetscanForByte— scan source for a target bytelinkToLocate— project*ast.Linkto resultpiToLocate— project PI node to resultlistItemValue— parse- key: valuelineheadingOnLine— find heading at a given linefrontMatterListItem— parse front-matter rowfrontMatterParentKey— walk up to parent keyoffsetAt— convert (line, col) to byte offset
isGlobPattern is a trivial one-liner with no branch.
Add a "// no test by design" exemption comment.
Note: Go vet requires test function names to start with
an uppercase letter after Test. The names below follow
the established codebase pattern (capitalize the first
letter of the helper name).
- For each of the 12 functions above, add at least
one
TestFunctionNameininternal/index/locate_test.go. Drive the helper directly, not throughLocate. - Add a
// no test by designcomment onisGlobPatternininternal/index/locate.go. -
go test ./internal/index/...passes. -
go vet ./internal/index/...passes.
-
locate_test.gocontainsTestHeadingInfo,TestLocateInAST,TestLinkContainsOffset,TestLinkCloseOffset,TestScanForByte,TestLinkToLocate,TestPiToLocate,TestListItemValue,TestHeadingOnLine,TestFrontMatterListItem,TestFrontMatterParentKey,TestOffsetAt. -
isGlobPatterncarries a "// no test by design" comment. -
go test ./internal/index/...is green. -
mdsmith check .is green.