syft/internal/formats/syftjson/encoder_test.go
Alex Goodman 4a82e4843a
add encoder tests for spdx-json and syft json
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
2021-10-10 18:56:16 -07:00

30 lines
774 B
Go

package syftjson
import (
"flag"
"testing"
"github.com/anchore/syft/internal/formats/common/testutils"
"github.com/anchore/syft/syft/format"
)
var updateJson = flag.Bool("update-json", false, "update the *.golden files for json presenters")
func TestJSONDirectoryPresenter(t *testing.T) {
catalog, metadata, distro := testutils.DirectoryInput(t)
testutils.AssertPresenterAgainstGoldenSnapshot(t,
format.NewPresenter(encoder, catalog, &metadata, distro),
*updateJson,
)
}
func TestJSONImagePresenter(t *testing.T) {
testImage := "image-simple"
catalog, metadata, distro := testutils.ImageInput(t, testImage)
testutils.AssertPresenterAgainstGoldenImageSnapshot(t,
format.NewPresenter(encoder, catalog, &metadata, distro),
testImage,
*updateJson,
)
}