mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
26 lines
719 B
Go
26 lines
719 B
Go
package integration
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/anchore/syft/syft/source"
|
|
)
|
|
|
|
func TestSbomMetadataComponent(t *testing.T) {
|
|
sbom, _ := catalogFixtureImage(t, "image-sbom-metadata-component", source.SquashedScope, "+sbom-cataloger")
|
|
|
|
expectedPkgs := []string{"first-subcomponent", "main-component"}
|
|
foundPkgs := []string{}
|
|
|
|
for sbomPkg := range sbom.Artifacts.Packages.Enumerate(pkg.JavaPkg) {
|
|
foundPkgs = append(foundPkgs, sbomPkg.Name)
|
|
}
|
|
|
|
// check if both the package in `.metadata.component` and the one in `.components` were found
|
|
if !reflect.DeepEqual(expectedPkgs, foundPkgs) {
|
|
t.Errorf("expected packages %v, got %v", expectedPkgs, foundPkgs)
|
|
}
|
|
}
|