Documentation
¶
Index ¶
- func CaptureTemplateOutput(t *testing.T, render func(io.Writer) (string, error)) (string, string)
- func CompareGolden(want, got any) string
- func Context() context.Context
- func LoadDocument(t *testing.T, path string) pkgopenapi.Document
- func LoadDocumentFromPath(path string) (pkgopenapi.Document, error)
- func LoadFormModel(path string) (pkgmodel.FormModel, error)
- func MustLoadFormModel(t *testing.T, path string) pkgmodel.FormModel
- func MustLoadOperations(t *testing.T, path string) map[string]pkgopenapi.Operation
- func MustReadGolden(t *testing.T, path string) []byte
- func MustReadGoldenString(t *testing.T, path string) string
- func WriteFormModel(t *testing.T, path string, value pkgmodel.FormModel)
- func WriteGolden(t *testing.T, path string, value any)
- func WriteMaybeGolden(t *testing.T, path string, data []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureTemplateOutput ¶
CaptureTemplateOutput executes a render function that writes to an io.Writer, returning both the string result and the writer contents. Tests can assert the renderer returns and writes the same payload without duplicating buffer setup.
func CompareGolden ¶
CompareGolden returns a diff string if the values differ.
func LoadDocument ¶
func LoadDocument(t *testing.T, path string) pkgopenapi.Document
LoadDocument reads a fixture and builds an openapi.Document using a file source. Testing helpers panic on failure to keep contract tests concise.
func LoadDocumentFromPath ¶
func LoadDocumentFromPath(path string) (pkgopenapi.Document, error)
LoadDocumentFromPath returns a Document without requiring testing.T, allowing callers to wire fixtures in setup functions while honouring go-form-gen.md:268-301.
func LoadFormModel ¶
LoadFormModel reads a JSON fixture into a FormModel, returning an error for callers managing setup outside of *testing.T.
func MustLoadFormModel ¶
MustLoadFormModel loads a JSON golden file into a FormModel structure.
func MustLoadOperations ¶
MustLoadOperations loads a JSON golden file into the provided map pointer.
func MustReadGolden ¶
MustReadGolden reads a golden file and returns its raw bytes.
func MustReadGoldenString ¶
MustReadGoldenString reads a golden file and returns its string content.
func WriteFormModel ¶
WriteFormModel writes a form model golden when UPDATE_GOLDENS is enabled. The JSON mirrors the builder output (including validation metadata) to keep snapshot diffs focused on behavioural changes.
func WriteGolden ¶
WriteGolden writes arbitrary data to a golden file when UPDATE_GOLDENS is set.
Types ¶
This section is empty.