How golden file testing works in goldie
masterGoldie is a utility for testing large data bodies (like API responses) by comparing actual output against a stored "golden file".
- Storage: Valid response data is saved in a fixture file (defaulting to the
testdatadirectory). - Assertion: During a test, goldie performs a byte comparison between the actual output and the golden file.
- Failure: If the bytes differ, the test fails.
- Updating: To update the golden files when the expected output changes, run your tests with the
-updateflag:
go test -update ./...