go-fixture

Go assertions against test fixtures with nice line diffs, and an -update flag for updating fixture or "golden" files.

MIT License

Stars
26
Committers
1

Fixture

Package fixture provides test assertions using test fixtures with nice line diffs, and an -update flag for bootstrapping & updating fixtures.

Example

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())
}

Sponsors

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: