test(xmlgen): whole-document golden fixtures (3/4) - #202
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: No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughChangesThe PR adds golden tests for invoice and SOAP envelope XML rendering. It adds JSON inputs, templates, expected XML outputs, template validation, and a README command for updating golden files. XML golden rendering coverage
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Other Merge Risk: 🔵 Low · up to A future rendering regression that removes invoice lines would produce a panic instead of the intended cardinality failure. Add the guard before merging for reliable test diagnostics. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
53eac5a to
828de48
Compare
828de48 to
b2ba118
Compare
b2ba118 to
7835564
Compare
7835564 to
b9cde46
Compare
b9cde46 to
eeec8fe
Compare
eeec8fe to
195de80
Compare
abca0fb to
31a1461
Compare
31a1461 to
706548c
Compare
The unit tests each isolate one behaviour. These prove a realistic template end to end: rendered from a data file, compared byte for byte against a golden, then unmarshalled and asserted field by field, so both the exact bytes and the semantic content are pinned. invoice exercises every conversion in one render -- a reference split across four elements, two dates moved between layouts, an enum mapped to a number, a fixed-decimal amount, an empty value spelled as a marker element, repeated elements filled from a table, a computed summary, and text carrying an ampersand, markup, non-ASCII and embedded tabs and newlines. It is also asserted to render identically with and without strict keys, which is the check a template's own tests should run: it is what turns a field renamed in a form schema from a silently blank element into a failure that names it. envelope covers the namespaced shape: two prefixes declared at the root, the reserved xml: prefix, a prefixed attribute, and a third prefix declared inside a range body so it is in scope only per iteration. It is unmarshalled by namespace URI rather than by prefix, which is what proves the declarations actually bind rather than merely appearing in the text. Both documents are invented. They are shaped after the conversions a real export needs, but carry no real registration numbers, tax identifiers or trade marks. Refs #189 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
706548c to
1030857
Compare
Problem
The unit tests in #199 and #201 each isolate one behaviour. Nothing yet proves a realistic template end to end — that the conversions compose correctly across a whole document rather than one element at a time.
Changes
Two fixtures. Each is rendered from a data file, compared byte for byte against a golden, then unmarshalled and asserted field by field — a golden alone only tells you the output changed, the field assertions tell you whether it is still correct.
invoiceexercises every conversion in one render: a reference split across four elements, two dates moved between layouts, an enum mapped to a number, a fixed-decimal amount, an empty value spelled as a<null/>marker, repeated elements filled from a table, a computed summary, a large number carrying no exponent,$.reaching the root from insidewith, and text carrying an ampersand, markup, non-ASCII and embedded tabs and newlines. It is also asserted to render identically with and withoutWithStrictKeys— the check a template's own tests should run, since that is what turns a field renamed in a form schema from a silently blank element into a failure that names it.envelopecovers the namespaced shape: two prefixes declared at the root, the reservedxml:lang, a prefixed attribute, and a third prefix declared inside arangebody so it is in scope only per iteration. It is unmarshalled by namespace URI rather than by prefix, which is what proves the declarations actually bind rather than merely appearing in the text.TestGolden_TemplatesValidaterunsValidateover every committed template, the way a registry or a CI sweep would.Both documents are invented — shaped after the conversions a real export needs, but carrying no real registration numbers, tax identifiers, trade marks or addresses.
Testing
155 subtests cumulative (17 added), race-clean, 0 lint issues. A tampered golden fails the suite, so the fixtures are load-bearing rather than decorative.
Separately, and not committed because it carries live business data, I rendered a template against a real SLTB blend sheet and its form JSON: 17 of 20 fields identical, all 25 repeated rows, all 7 empty-value markers, and a multi-line warehouse address round-tripping exactly. The three differences are legacy Java number formatting we chose not to reproduce —
8522vs8522.0,162vs162.0,16336200vs1.63362E7. Worth revisiting before the first live submission if the consuming system turns out to be a legacy reader rather than a real parser.Related
Implements #189. Stacked chain — 3 of 4:
#199 engine → #201 helpers and resolvers → #202 (this) → #200 failure paths
Summary by CodeRabbit
Documentation
Tests