A test fixture is prepared input or reference data used to evaluate software under test. For generated HTML, store the expected output as a file in testdata; this reference is commonly called a golden file. section 11.1.1
A practical fixture-based HTTP test follows these steps:
- Create an httptest response recorder and invoke the handler. section 11.1.1
- Compare the generated body with the fixture, while recognizing that strict equality makes whitespace changes significant. section 11.1.1
Golden HTML fixture
Keep the expected page in testdata/index.html rather than embedding HTML in a Go test. The test then compares the handler response with that reference and detects output changes automatically. section 11.1.1









