Package fixture provides test assertions using test fixtures with nice line diffs, and an -update flag for bootstrapping & updating fixtures.
func TestGenerate(t *testing.T) {
// ... pretend we generate some client code here for TypeScript
var act bytes.Buffer
err = tsclient.Generate(&act)
assert.NoError(t, err, "generating")
// assert the contents of act.Bytes() to the test fixture ./testdata/client.ts
fixture.Assert(t, "client.ts", act.Bytes())
}
This project is sponsored by CTO.ai, making it easy for development teams to create and share workflow automations without leaving the command line.
And my GitHub sponsors: