test(metadata): apiMetadata npm-fields round-trip test [#847] #848
Reference in New Issue
Block a user
Delete Branch "fix/apimetadata-npm-fields"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #847 (regression class from #827): the npm/mcp metadata fields
npm_package,node_minimum, andpublish_targetmust round-trip overGET/PUT /api/v1/repos/{owner}/{repo}/metadata.Investigation
On
dev, the handler inrouters/api/v1/repo/manifest.goalready declares all three fields on theapiMetadatastruct and wires both directions:m.NodeMinimum/m.NpmPackage/m.PublishTargetinto the response.setStr("node_minimum"/"npm_package"/"publish_target", ...)partial-merge persists them.The underlying model (
models/repo/repo_manifest.go) and migration (models/migrations/v1_27/v373.go) define the columns:NpmPackageTEXT 'npm_package'NodeMinimumVARCHAR(20) 'node_minimum'PublishTargetVARCHAR(50) 'publish_target'This landed in commit
5f85b27(feat(metadata): persist npm/mcp fields ... [#363]). The bug reported in #847 was observed on prod, which lagsdev; ondevthe serialization/persistence is already correct.What this PR adds
No round-trip test guarded the behavior, so a future refactor of the fixed-shape
apiMetadatastruct could silently reintroduce #847. This PR addstests/integration/api_repo_metadata_test.go—TestAPIRepoMetadataNpmFieldsRoundTrip— which PUTs the three fields (as adminuser1, matching thereqAdmin()gate) and asserts they are echoed by the PUT response and read back by a subsequent GET.Notes
dev.Refs #847, #827.
https://claude.ai/code/session_015UauDPfYC8S2mdUhoSK8zQ
The GET/PUT /api/v1/repos/{owner}/{repo}/metadata handler already declares node_minimum, npm_package and publish_target on the apiMetadata struct and wires both the GET-serialize and PUT-persist paths (commit5f85b27, #363). No round-trip test guarded that behavior, so a regression could silently reintroduce #847 (from #827) where these DB columns are un-settable and un-readable over the REST API. Add an integration test that PUTs the three fields and asserts they are echoed by the PUT response and read back by a subsequent GET. Authored-by: Moko ConsultingWIP: fix(metadata): guard npm/mcp field round-trip in apiMetadata [#847]to test(metadata): apiMetadata npm-fields round-trip test [#847]