mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 23:00:42 -08:00
BREAKING(report): migrate to new json schema (#1265)
This commit is contained in:
@@ -6,11 +6,11 @@ package integration
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/aquasecurity/trivy/pkg/commands"
|
||||
)
|
||||
@@ -118,15 +118,9 @@ func TestFilesystem(t *testing.T) {
|
||||
}
|
||||
|
||||
// Setup the output file
|
||||
var outputFile string
|
||||
outputFile := filepath.Join(t.TempDir(), "output.json")
|
||||
if *update {
|
||||
outputFile = tt.golden
|
||||
} else {
|
||||
output, err := os.CreateTemp("", "integration")
|
||||
require.NoError(t, err)
|
||||
assert.Nil(t, output.Close())
|
||||
defer os.Remove(output.Name())
|
||||
outputFile = output.Name()
|
||||
}
|
||||
|
||||
osArgs = append(osArgs, "--output", outputFile)
|
||||
@@ -140,12 +134,10 @@ func TestFilesystem(t *testing.T) {
|
||||
assert.Nil(t, app.Run(osArgs))
|
||||
|
||||
// Compare want and got
|
||||
want, err := os.ReadFile(tt.golden)
|
||||
assert.NoError(t, err)
|
||||
got, err := os.ReadFile(outputFile)
|
||||
assert.NoError(t, err)
|
||||
want := readReport(t, tt.golden)
|
||||
got := readReport(t, outputFile)
|
||||
|
||||
assert.JSONEq(t, string(want), string(got))
|
||||
assert.Equal(t, want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user