test(xmlgen): cover failure paths with whole-document fixtures (4/4) - #200
Open
sthanikan2000 wants to merge 1 commit into
Open
sthanikan2000 wants to merge 1 commit into
sthanikan2000 wants to merge 1 commit into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 15, 2026 10:30
a0b4ac9 to
88c4f3c
Compare
sthanikan2000
changed the base branch from
feature/xmlgen
to
feature/xmlgen-golden
September 15, 2026 10:32
sthanikan2000
added this pull request to stack #204
September 16, 2026 04:55
This was referenced Sep 16, 2026
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 09:12
88c4f3c to
c8dab27
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 09:58
c8dab27 to
2843f72
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 10:06
2843f72 to
d3c8b6a
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 10:16
d3c8b6a to
1293adc
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 10:35
1293adc to
938e02b
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 15:50
938e02b to
195de80
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 15:56
7814517 to
eceaa3c
Compare
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 17, 2026 16:08
eceaa3c to
86cd6c5
Compare
The golden fixtures proved the conversions work, but only on the happy path. Nothing showed what a failure looks like on a document of realistic size, and an error that says only "invalid XML" is of no use against a hundred-element declaration. Adds eight deliberately broken templates under testdata/invalid/, each a mistake somebody could plausibly commit -- a range at the top level with nothing wrapping it, an element never closed, a namespace prefix typed one letter wrong, a DOCTYPE, an unsupplied resolver, an if with no end, raw used on a value containing an ampersand, and a whole object printed where text belongs. Each is rendered against the real invoice data, and each case asserts the message names what went wrong, so it can be found in the template. For bad data, the real invoice fixture is patched at one point rather than duplicated per case: a date in the wrong layout, a non-numeric amount, an object where text belongs, a table that is not a table. That keeps the broken value beside its assertion and stops these drifting out of step with invoice.json. A second test records which faults Validate catches without data -- the parse-time ones -- and which can only surface from Generate. That is the difference between a template failing when it is stored and failing when someone presses submit. Refs #189 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
sthanikan2000
force-pushed
the
feature/xmlgen-failure-tests
branch
from
September 18, 2026 10:27
86cd6c5 to
4bfb09f
Compare
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.
Problem
The golden fixtures in #202 prove the conversions work, but only on the happy path. Nothing shows what a failure looks like on a document of realistic size — and an error that says only "invalid XML" is of no use against a hundred-element declaration.
Changes
Eight deliberately broken templates under
testdata/invalid/, each a mistake somebody could plausibly commit, rendered against the real invoice data:two-roots.tmplrangeat the top level with nothing wrapping itErrMultipleRootsunclosed-element.tmpl</Header>forgottenErrMalformedXMLundeclared-prefix.tmplsoapp:typed one letter wrongErrUndeclaredNamespacedoctype.tmplDOCTYPEGo ignores but a receiving parser will notErrDoctypeNotAllowedunknown-function.tmplErrParseTemplatesyntax-error.tmplifwith noendErrParseTemplateraw-bypass.tmplrawon a value containing&ErrMalformedXMLobject-as-text.tmplErrUnsupportedValueEach case asserts the message names what went wrong —
soapp,codelist,Header— so it can be found in the template.For bad data, the real
invoice.jsonis patched at one point rather than duplicated per case: a date in the wrong layout, a non-numeric amount, an object where text belongs, a table that is not a table, and bytes that are not JSON at all. That keeps the broken value beside its assertion and stops these drifting out of step with the fixture.A second test records which faults
Validatecatches without data — the parse-time ones — and which can only surface fromGenerate. That is the difference between a template failing when it is stored and failing when someone presses submit.Testing
180 subtests cumulative (25 added), race-clean, 0 lint issues. Statement coverage is unchanged at 88.7%, which is the expected result: these paths were already exercised. What is new is proof the errors are legible on a realistic document rather than a one-element toy.
Writing these found a real defect in #202's fixture — under
WithStrictKeysthe invoice template tripped on a key deliberately left absent, so the fixture could not pass strict mode at all. That fix lives in #202, which is also what keeps this PR purely additive: 9 new files, zero modifications.Related
Implements #189. Stacked chain — 4 of 4:
#199 engine → #201 helpers and resolvers → #202 golden fixtures → #200 (this)