BREAKING(report): migrate to new json schema (#1265)

This commit is contained in:
Teppei Fukuda
2021-10-04 16:22:24 +09:00
committed by GitHub
parent da905108b4
commit b37f682ee2
51 changed files with 131927 additions and 130069 deletions

View File

@@ -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)
})
}
}