mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 00:13:15 +01:00
chore: add a test
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
823723f510
commit
7ea37792f1
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/anchore/syft/syft/file"
|
||||
"github.com/anchore/syft/syft/format/internal/cyclonedxutil"
|
||||
"github.com/anchore/syft/syft/format/internal/testutil"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
@ -27,6 +28,31 @@ func getEncoder(t testing.TB) sbom.FormatEncoder {
|
||||
return enc
|
||||
}
|
||||
|
||||
func Test_noTypedNils(t *testing.T) {
|
||||
s := sbom.SBOM{
|
||||
Artifacts: sbom.Artifacts{
|
||||
FileMetadata: map[file.Coordinates]file.Metadata{},
|
||||
FileDigests: map[file.Coordinates][]file.Digest{},
|
||||
},
|
||||
}
|
||||
c := file.NewCoordinates("/dev/null", "123")
|
||||
s.Artifacts.FileMetadata[c] = file.Metadata{
|
||||
Path: "/dev/null",
|
||||
}
|
||||
s.Artifacts.FileDigests[c] = []file.Digest{}
|
||||
|
||||
enc, err := NewFormatEncoderWithConfig(EncoderConfig{
|
||||
Version: "1.6",
|
||||
Pretty: true,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
contents := bytes.Buffer{}
|
||||
err = enc.Encode(&contents, s)
|
||||
require.NoError(t, err)
|
||||
require.NotContains(t, contents.String(), `"hashes": null`)
|
||||
}
|
||||
|
||||
func TestPrettyOutput(t *testing.T) {
|
||||
run := func(opt bool) string {
|
||||
enc, err := NewFormatEncoderWithConfig(EncoderConfig{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user