sebdah / goldie

Golden file testing for Go
MIT License
228 stars 19 forks source link

Clean testdata/fixture dir before generate new goldie file #19

Closed ltpquang closed 5 years ago

ltpquang commented 5 years ago

Should we clean the output directory before running go test -update? Since every time I update the test cases that changes the test cases' names, the old goldie files stay untouch, and I need to delete the files manually to keep the dir clean and clear.

sebdah commented 5 years ago

This is a good suggestion! Feel free to take a stab at it if you want. I think best would be to add a flag e.g. -clean or so, rather than cleaning all by default. The reason being that if cleaning would be the default the following would wipe fixtures for other test cases unintentionally; go test -update -run SomeTest ./...

ltpquang commented 5 years ago

Hi @sebdah, I've opened PR #23, please take a look.

The idea is initialize a timestamp every time we run go test, and then use it as directories' signature, for clean them if required by -clean flag.

sebdah commented 5 years ago

This was released just now in version v2.2.0. Thank you @ltpquang for the submitted PR :heart: