Verify icon indicating copy to clipboard operation
Verify copied to clipboard

Add UniqueForFileExtension to allow snapshots with different extension to coexist

Open joelverhagen opened this issue 2 years ago • 6 comments

Fix https://github.com/VerifyTests/Verify/issues/1081

joelverhagen avatar Nov 29 '23 05:11 joelverhagen

how would this work given a single call to Verify can produce multiple files with different file extensions?

SimonCropp avatar Nov 30 '23 04:11 SimonCropp

how would this work given a single call to Verify can produce multiple files with different file extensions?

I think the concept that I'm trying to describe is that Verify should optionally leave files alone if they do not have an extension overlapping with the verified list of targets. The default behavior is that files with matching prefix but different extension are deleted as part of the verify process.

I added a couple of tests to ensure the behavior. In psuedo code Verify(txt, xml) followed by Verify(csv, log) should be workable since all of those snapshot files have different paths. But Verify(txt, xml) following by Verify(xml, log) (where the snapshot with xml extension is checked for two different contents) will fail as expected.

joelverhagen avatar Nov 30 '23 17:11 joelverhagen

Is there another approach I should take with this PR? I'd like to use file extension as a differentiator in a snapshot file instead of having the verify process delete these different files.

joelverhagen avatar Dec 12 '23 02:12 joelverhagen

what if i changed the behavior to "multiple test cannot produce the same verified file" ?

SimonCropp avatar Dec 12 '23 09:12 SimonCropp

what if i changed the behavior to "multiple test cannot produce the same verified file" ?

This sounds like a "block" rather than "allow" behavior. For that idea, what would happen if Verify call 1 produces foo.verified.txt and Verify call 2 produces foo.verified.csv? Verify call 2 would fail? I think I'm a little unclear on what that means.

I'd be happy to give it a try if you have a POC or can guide me to implementing the behavior you're thinking of!

joelverhagen avatar Dec 13 '23 14:12 joelverhagen

For that idea, what would happen if Verify call 1 produces foo.verified.txt and Verify call 2 produces foo.verified.csv? Verify call 2 would fail?

no it would not fail

i will put together the change and let u know tomorrow

SimonCropp avatar Dec 13 '23 20:12 SimonCropp

closing this one. I suggest instead you submit a PR that meets your requirements with a single Verify call

SimonCropp avatar Apr 12 '24 11:04 SimonCropp