approvals / go-approval-tests

Apache License 2.0
90 stars 22 forks source link

Unexpected default path of approved files #16

Open objarni opened 3 years ago

objarni commented 3 years ago

Go has a convention to put test data files under projectroot/testdata, I think it makes sense to store approved (and temporary/received files possibly too) there by default. Possibly making this configurable, but that is less important imho.

See https://ieftimov.com/post/testing-in-go-golden-files/ for more info. Side note: Maybe that blogger is interested in helping out on this lib too, (s)he seems to know quite a bit on approval tests, even if the terminology is somewhat dated (golden files in the blog post).

dertseha commented 3 years ago

As a detail, testdata does not have to be in the root of the project, it is generally ignored. So it is possible to have package-specific testdata subfolder holding related samples.

As per go help test:

The go tool will ignore a directory named "testdata", making it available to hold ancillary data needed by the tests.