github.com/anchore/syft@v1.38.2/cmd/syft/internal/test/integration/sbom_metadata_component_test.go (about) 1 package integration 2 3 import ( 4 "reflect" 5 "testing" 6 7 "github.com/anchore/syft/syft/pkg" 8 "github.com/anchore/syft/syft/source" 9 ) 10 11 func TestSbomMetadataComponent(t *testing.T) { 12 sbom, _ := catalogFixtureImage(t, "image-sbom-metadata-component", source.SquashedScope, "+sbom-cataloger") 13 14 expectedPkgs := []string{"first-subcomponent", "main-component"} 15 foundPkgs := []string{} 16 17 for sbomPkg := range sbom.Artifacts.Packages.Enumerate(pkg.JavaPkg) { 18 foundPkgs = append(foundPkgs, sbomPkg.Name) 19 } 20 21 // check if both the package in `.metadata.component` and the one in `.components` were found 22 if !reflect.DeepEqual(expectedPkgs, foundPkgs) { 23 t.Errorf("expected packages %v, got %v", expectedPkgs, foundPkgs) 24 } 25 }