Skip to content

test: move public-API tests to external _test packages#1167

Closed
cloudnativeninja wants to merge 6 commits into
getkin:masterfrom
cloudnativeninja:chore/external-test-packages
Closed

test: move public-API tests to external _test packages#1167
cloudnativeninja wants to merge 6 commits into
getkin:masterfrom
cloudnativeninja:chore/external-test-packages

Conversation

@cloudnativeninja

Copy link
Copy Markdown
Contributor

Summary

Moves test files that exercise only the public API to external _test packages so the type system enforces that boundary. Test files that genuinely exercise unexported behaviour (private types, methods, struct fields, helpers) stay as internal package <pkg> tests — no public API surface is widened, no helper code is duplicated.

What changed

  • 66 internal *_test.go files moved to package <pkg>_test, with the package's own import path added and every package-level reference qualified (e.g. NewLoader()openapi3.NewLoader()).
  • 43 internal test files stay internal because they reference unexported identifiers, or because they consume a helper defined in such a file (closure of the helper-cascade).
  • No production code touched. go.mod / go.sum unchanged.

Stay-internal files

Package Files Reason
openapi3 29 5 reference defaultJoin/setRefPath/multiErrorForOneOf/multiErrorForAllOf/compilePattern/intoGoRegexp; 24 cascade through encoding(), example(), testCase helpers
openapi3filter 12 reference headerCT, validateRequest, decodeBody, decodeStyledParameter, encodeBody, deepGet, deepSet, prefixInvalidCT, toJSONPointer, validateResponseHeader, setupTestRouter
openapi2 1 marsh_test.go calls unexported unmarshal
routers/gorillamux 1 router_test.go constructs srv{schemes,host,base,server,varsUpdater} literals with unexported fields

Test plan

  • go test ./... — 5349 passed (matches baseline)
  • go vet ./... — clean
  • gofmt -l . — clean
  • goimports -l . — clean

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.

1 participant