Documentation
¶
Overview ¶
Package examples provides reusable helpers for converting GOBL example documents into calculated, validated JSON envelopes and verifying them against golden output. It captures the conventions used by GOBL's own example suite (a fixed envelope UUID, envelope-vs-document detection, and tab-indented output) so that external addon and converter modules can ship example documents tested exactly the same way.
Run is the single test entry point; Convert, Sources, GoldenPath and IsEnvelope are exposed for callers that need a custom harness. The package is intended for use from tests (Run takes a *testing.T), and the addon(s) under test must already be registered in the test binary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TestUUID = uuid.MustParse("8a51fd30-2a27-11ee-be56-0242ac120002")
TestUUID is assigned to every converted envelope so that golden output is deterministic regardless of the source document's own UUID.
Functions ¶
func Convert ¶
Convert reads a GOBL example (YAML or JSON) and returns the calculated, validated envelope as tab-indented JSON. When asEnvelope is true the input is parsed as a full gobl.Envelope and calculated; otherwise it is treated as a bare document and wrapped with gobl.Envelop. The envelope UUID is forced to TestUUID so the output is stable for golden comparison.
func GoldenPath ¶
GoldenPath returns the expected output path for a source example: a JSON file of the same base name inside a sibling `out/` directory.
func IsEnvelope ¶
IsEnvelope reports whether the source path holds a full envelope (by the `.env.` naming convention) rather than a bare document.
func Run ¶
Run discovers the example sources under root, converts each, and either updates the golden output (when update is true) or compares against it. Extra skip fragments are passed through to Sources. Each example runs as a named subtest. The addon(s) under test must already be registered in the test binary (e.g. via a blank import).
Types ¶
This section is empty.