Documentation
¶
Overview ¶
Package golden hosts the M9 unified golden-file workflow: Compare / CompareSVG / CompareJSON sharing the `-update` flag declared in tests/integration/output_json_test.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare diffs `got` against the golden file at tests/golden/<goldenPath>. On the `-update` flag (declared in tests/integration/output_json_test.go and shared by all callers), rewrites the golden file and passes. Without -update, fails the test on byte mismatch with a first-divergent-offset diff window.
func CompareJSON ¶
CompareJSON re-marshals both sides through json.MarshalIndent with the standard 2-space indent so per-key whitespace drift between encoders does not break the comparison.
func CompareSVG ¶
CompareSVG applies NormalizeSVG to both sides before byte-diffing. Used for SVG goldens that must tolerate Go-runtime / chromedp drift in non-semantic bytes (attribute order, whitespace inside text nodes, dynamic footer fragments).
func NormalizeSVG ¶
NormalizeSVG produces a byte-stable representation of an SVG document by:
- Replacing the dynamic footer fragments ("Last updated <time>" and "<repo>/github-metrics@<version>") with __MASKED__ so test runs don't fluctuate with timestamps or version strings.
- Re-emitting elements with their attributes sorted alphabetically.
- Collapsing whitespace inside text nodes to a single space.
- Dropping XML comments.
The output is suitable for MD5-comparison golden files. Used internally by CompareSVG; exported so callers that need raw normalization (e.g., diffing two in-flight SVGs without a golden file) can reuse the helper.
Types ¶
This section is empty.