Repository navigation
test: generated tests check each union's null, and that nothing is dropped - #82
Merged
Merged
Conversation
…opped Every union gets a generated Null check: holding no alternative, it encodes as null, and null decodes as it, as an API sends a member it leaves unset. apitest.RoundTrip, bumped, now also checks each round-tripped variant refuses or keeps a member no type declares, never drops it. In notion, these reach the null and error paths of every union's decoder, which no test did: coverage, as devtool measures it, goes from 77.8% to 83.6%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This extends the generated round-trip tests, part of fixing go-api-libs/notion#21. It builds on go-api-libs/api#8, now merged; this branch pins go-api-libs/api at its master.
TestUnions_Null, generated for every union (tagged structs and unimplemented unions excluded): checks that a union holding no alternative encodes asnull, and thatnulldecodes as a union holding none (apitest.Null). This is the"cover": nullcase.apitest.RoundTrip, from the api bump: each round-tripped alternative must now refuse a member no type declares, or keep it. It must never drop it silently. That makes the generated tests check what debug mode depends on.Why: in notion, about 1,260 uncovered statements were each union decoder's
nullbranch and its per-alternativereturn err, which no test reached. Measured with Go 1.27.4, devtool's version: notion goes from 77.8% to 83.6%. I checked against notion and pixellab with localreplacedirectives: no generated type drops a member or mishandlesnull.The golden and debug test packages gain the
nullchecks, andTestDocument_NullUnionscovers which types qualify.Separately: with codegen#81, pixellab's replay test now fails. Its recorded
last_response.detailholds error messages, but pixellab's generator types it as the styleDetailenum. That's a pixellab fix, not part of this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_019QCb1AfnATvpBQCH3PrX7Y