mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* update SPDX license list from 3.13 to 3.14 Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove license list version from spdx snapshot unit tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package packages
|
|
|
|
import (
|
|
"flag"
|
|
"regexp"
|
|
"testing"
|
|
)
|
|
|
|
var updateSpdxJson = flag.Bool("update-spdx-json", false, "update the *.golden files for spdx-json presenters")
|
|
|
|
func TestSPDXJSONDirectoryPresenter(t *testing.T) {
|
|
catalog, metadata, _ := presenterDirectoryInput(t)
|
|
assertPresenterAgainstGoldenSnapshot(t,
|
|
NewSPDXJSONPresenter(catalog, metadata),
|
|
*updateSpdxJson,
|
|
spdxJsonRedactor,
|
|
)
|
|
}
|
|
|
|
func TestSPDXJSONImagePresenter(t *testing.T) {
|
|
testImage := "image-simple"
|
|
catalog, metadata, _ := presenterImageInput(t, testImage)
|
|
assertPresenterAgainstGoldenImageSnapshot(t,
|
|
NewSPDXJSONPresenter(catalog, metadata),
|
|
testImage,
|
|
*updateSpdxJson,
|
|
spdxJsonRedactor,
|
|
)
|
|
}
|
|
|
|
func spdxJsonRedactor(s []byte) []byte {
|
|
// each SBOM reports the time it was generated, which is not useful during snapshot testing
|
|
s = regexp.MustCompile(`"created": .*`).ReplaceAll(s, []byte("redacted"))
|
|
// the license list will be updated periodically, the value here should not be directly tested in snapshot tests
|
|
return regexp.MustCompile(`"licenseListVersion": .*`).ReplaceAll(s, []byte("redacted"))
|
|
}
|