github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/swift/parse_package_resolved_test.go (about) 1 package swift 2 3 import ( 4 "testing" 5 6 "github.com/anchore/syft/syft/artifact" 7 "github.com/anchore/syft/syft/file" 8 "github.com/anchore/syft/syft/pkg" 9 "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" 10 ) 11 12 func TestParsePackageResolved(t *testing.T) { 13 fixture := "test-fixtures/Package.resolved" 14 locations := file.NewLocationSet(file.NewLocation(fixture)) 15 expectedPkgs := []pkg.Package{ 16 { 17 Name: "swift-algorithms", 18 Version: "1.0.0", 19 PURL: "pkg:swift/github.com/apple/swift-algorithms.git/swift-algorithms@1.0.0", 20 Locations: locations, 21 Language: pkg.Swift, 22 Type: pkg.SwiftPkg, 23 MetadataType: pkg.SwiftPackageManagerMetadataType, 24 Metadata: pkg.SwiftPackageManagerMetadata{ 25 Revision: "b14b7f4c528c942f121c8b860b9410b2bf57825e", 26 }, 27 }, 28 { 29 Name: "swift-async-algorithms", 30 Version: "0.1.0", 31 PURL: "pkg:swift/github.com/apple/swift-async-algorithms.git/swift-async-algorithms@0.1.0", 32 Locations: locations, 33 Language: pkg.Swift, 34 Type: pkg.SwiftPkg, 35 MetadataType: pkg.SwiftPackageManagerMetadataType, 36 Metadata: pkg.SwiftPackageManagerMetadata{ 37 Revision: "9cfed92b026c524674ed869a4ff2dcfdeedf8a2a", 38 }, 39 }, 40 { 41 Name: "swift-atomics", 42 Version: "1.1.0", 43 PURL: "pkg:swift/github.com/apple/swift-atomics.git/swift-atomics@1.1.0", 44 Locations: locations, 45 Language: pkg.Swift, 46 Type: pkg.SwiftPkg, 47 MetadataType: pkg.SwiftPackageManagerMetadataType, 48 Metadata: pkg.SwiftPackageManagerMetadata{ 49 Revision: "6c89474e62719ddcc1e9614989fff2f68208fe10", 50 }, 51 }, 52 { 53 Name: "swift-collections", 54 Version: "1.0.4", 55 PURL: "pkg:swift/github.com/apple/swift-collections.git/swift-collections@1.0.4", 56 Locations: locations, 57 Language: pkg.Swift, 58 Type: pkg.SwiftPkg, 59 MetadataType: pkg.SwiftPackageManagerMetadataType, 60 Metadata: pkg.SwiftPackageManagerMetadata{ 61 Revision: "937e904258d22af6e447a0b72c0bc67583ef64a2", 62 }, 63 }, 64 { 65 Name: "swift-numerics", 66 Version: "1.0.2", 67 PURL: "pkg:swift/github.com/apple/swift-numerics/swift-numerics@1.0.2", 68 Locations: locations, 69 Language: pkg.Swift, 70 Type: pkg.SwiftPkg, 71 MetadataType: pkg.SwiftPackageManagerMetadataType, 72 Metadata: pkg.SwiftPackageManagerMetadata{ 73 Revision: "0a5bc04095a675662cf24757cc0640aa2204253b", 74 }, 75 }, 76 } 77 78 // TODO: no relationships are under test yet 79 var expectedRelationships []artifact.Relationship 80 81 pkgtest.TestFileParser(t, fixture, parsePackageResolved, expectedPkgs, expectedRelationships) 82 }