zarf icon indicating copy to clipboard operation
zarf copied to clipboard

Better testing of large strings / large amount of output

Open AustinAbro321 opened this issue 11 months ago • 1 comments

Describe what should be investigated or refactored

Usually when testing a large output like on zarf dev find-images we only check a few strings such as require.contains("string-we-hope-to-find"), however this comes with some disadvantages. That string could appear more than once when we don't want it to, we could also get extra output we don't expect and aren't testing.

One solution we've tried is to create a text file of what we are looking for and ensure standard output contains the contents of the text file. This can be a brittle approach though and when something changes it can be hard to know exactly what changed.

In other languages I've used the approval tests framework https://github.com/approvals/go-approval-tests, which helped this process be more convenient, though in go it doesn't seem very popular or maintained. I do know the creator of approval tests, so I could pair with him to update the package if we wanted to

AustinAbro321 avatar Mar 07 '24 15:03 AustinAbro321

Let's start to implement this with golden files and use test/testing directories

schristoff-du avatar May 16 '24 15:05 schristoff-du