mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 06:26:30 +01:00
Fix file creation for output options (#875)
This commit is contained in:
@@ -10,10 +10,26 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/acarl005/stripansi"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
type traitAssertion func(tb testing.TB, stdout, stderr string, rc int)
|
||||
|
||||
func assertFileOutput(tb testing.TB, path string, assertions ...traitAssertion) traitAssertion {
|
||||
tb.Helper()
|
||||
|
||||
return func(tb testing.TB, _, stderr string, rc int) {
|
||||
content, err := os.ReadFile(path)
|
||||
require.NoError(tb, err)
|
||||
contentStr := string(content)
|
||||
|
||||
for _, assertion := range assertions {
|
||||
// treat the file content as stdout
|
||||
assertion(tb, contentStr, stderr, rc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertJsonReport(tb testing.TB, stdout, _ string, _ int) {
|
||||
tb.Helper()
|
||||
var data interface{}
|
||||
|
||||
Reference in New Issue
Block a user