approvals / go-approval-tests

Apache License 2.0
86 stars 22 forks source link

Add an easy bulk approve-all method #47

Open davidalpert opened 7 months ago

davidalpert commented 7 months ago

While working with approval tests it is sometimes the case that one code change can result in many similar changes to a set of previously baselined approved files.

In this scenario it can be simpler to bulk approve all and use source control tools to scan the approved files for diffs rather than to review each received vs approval one by one in the configured diff reporter.

It would be helpful to add a mechanism to bulk approve all verifications, either as another verifyOptions helper https://github.com/approvals/go-approval-tests/blob/32d5677069bd623f06e909e11474d27400539dae/approvals.go#L270-L273

Or as an environment variable.

In some ruby-based approval use cases, for example, I have patched in an optional environment variable APPROVE_ALL; when set to something non-empty (e.g. 1 or 'true') all received diffs are approved.

tyrcho commented 3 months ago

a possible workaround (this is what I usually do) :

 find . -name "*received.txt" -exec bash -c 'mv $0 ${0/received/approved}' {} \;