The current invoice tests are hard to extend as they build the complete database by hand and try to parse the complete invoice.
This PR introduces golden test for generating invoices. It uses the report function to fill the database with fake data and we compare the resulting invoice with a golden file. This still requires us to actually manually look at the created invoice but we should be able to spot errors that are introduced.
The test code is not especially more readable but it's a bit simpler to setup complex test cases. We handle a lot of edge cases we did not consider earlier.
See #55
Checklist
[x] Categorize the PR by setting a good title and adding one of the labels:
bug, enhancement, documentation, change, breaking, dependency
as they show up in the changelog
I introduce these golden test as part of the invoice test in ./pkg/invoice. We generally do more of an integration test and also test the reporting. Should this rather be moved to ./tests/ or similar?
Summary
The current invoice tests are hard to extend as they build the complete database by hand and try to parse the complete invoice.
This PR introduces golden test for generating invoices. It uses the report function to fill the database with fake data and we compare the resulting invoice with a golden file. This still requires us to actually manually look at the created invoice but we should be able to spot errors that are introduced.
The test code is not especially more readable but it's a bit simpler to setup complex test cases. We handle a lot of edge cases we did not consider earlier.
See #55
Checklist
bug
,enhancement
,documentation
,change
,breaking
,dependency
as they show up in the changelog