-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
🚀 Feature Proposal
In osv-scanner we have this:
func RunAndMatchSnapshots(t *testing.T, tc Case) {
t.Helper()
stdout, stderr := RunAndNormalize(t, tc)
testutility.NewSnapshot().MatchText(t, stdout)
testutility.NewSnapshot().WithWindowsReplacements(map[string]string{
"CreateFile": "stat",
}).MatchText(t, stderr)
}which results in snapshots like this:
[TestCommand/no_lockfiles_without_recursion_but_with_allow_flag_are_fine - 1]
Scanning dir ./testdata/locks-none
No package sources found
No issues found
---
[TestCommand/no_lockfiles_without_recursion_but_with_allow_flag_are_fine - 2]
---
It would be cool if we could label snapshots, e.g.
testutility.NewSnapshot().WithLabel("stdout").MatchText(t, stdout)
testutility.NewSnapshot().WithLabel("stderr").WithWindowsReplacements(map[string]string{
"CreateFile": "stat",
}).MatchText(t, stderr)which would result in:
[TestCommand/no_lockfiles_without_recursion_but_with_allow_flag_are_fine - 1 - stdout]
Scanning dir ./testdata/locks-none
No package sources found
No issues found
---
[TestCommand/no_lockfiles_without_recursion_but_with_allow_flag_are_fine - 2 - stderr]
---
Note, under the hood testutility.NewSnapshot translates to snaps.MatchSnapshot
Motivation
This would make it easier to review snapshots, while still allowing them to be ordered
Example
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request