github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/snap/parse_integration_test.go (about) 1 package snap 2 3 import ( 4 "testing" 5 6 "github.com/anchore/syft/syft/file" 7 "github.com/anchore/syft/syft/pkg" 8 "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" 9 ) 10 11 func TestParseSnapYaml(t *testing.T) { 12 fixture := "test-fixtures/snap.yaml" 13 locations := file.NewLocationSet(file.NewLocation(fixture)) 14 15 expected := []pkg.Package{ 16 { 17 Name: "test-snap", 18 Version: "1.0.0", 19 Type: pkg.DebPkg, 20 PURL: "pkg:generic/snap/test-snap@1.0.0?arch=amd64&base=core20&type=app", 21 Locations: locations, 22 Metadata: pkg.SnapEntry{ 23 SnapType: pkg.SnapTypeApp, 24 Base: "core20", 25 SnapName: "test-snap", 26 SnapVersion: "1.0.0", 27 Architecture: "amd64", 28 }, 29 }, 30 } 31 32 pkgtest.TestFileParser(t, fixture, parseSnapYaml, expected, nil) 33 } 34 35 func TestParseSystemManifest(t *testing.T) { 36 fixture := "test-fixtures/manifest.yaml" 37 locations := file.NewLocationSet(file.NewLocation(fixture)) 38 39 expected := []pkg.Package{ 40 { 41 Name: "grub-efi-amd64-signed", 42 Version: "1.202+2.12-1ubuntu7", 43 Type: pkg.DebPkg, 44 PURL: "pkg:deb/ubuntu/grub-efi-amd64-signed@1.202%2B2.12-1ubuntu7?arch=amd64", // URL encoded 45 Locations: locations, 46 Metadata: pkg.SnapEntry{ 47 SnapType: pkg.SnapTypeApp, // Default type when gadget not detected from name 48 Base: "core24", 49 SnapName: "pc", 50 SnapVersion: "24-0.1", 51 Architecture: "amd64", // From architectures array 52 }, 53 }, 54 { 55 Name: "shim-signed", 56 Version: "1.56+15.7-0ubuntu1", 57 Type: pkg.DebPkg, 58 PURL: "pkg:deb/ubuntu/shim-signed@1.56%2B15.7-0ubuntu1?arch=amd64", // URL encoded 59 Locations: locations, 60 Metadata: pkg.SnapEntry{ 61 SnapType: pkg.SnapTypeApp, // Default type when gadget not detected from name 62 Base: "core24", 63 SnapName: "pc", 64 SnapVersion: "24-0.1", 65 Architecture: "amd64", // From architectures array 66 }, 67 }, 68 } 69 70 pkgtest.TestFileParser(t, fixture, parseSystemManifest, expected, nil) 71 }