github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/dart/parse_pubspec_lock_test.go (about) 1 package dart 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 TestParsePubspecLock(t *testing.T) { 13 fixture := "test-fixtures/pubspec.lock" 14 fixtureLocationSet := file.NewLocationSet(file.NewLocation(fixture)) 15 expected := []pkg.Package{ 16 { 17 Name: "ale", 18 Version: "3.3.0", 19 PURL: "pkg:pub/ale@3.3.0?hosted_url=pub.hosted.org", 20 Locations: fixtureLocationSet, 21 Language: pkg.Dart, 22 Type: pkg.DartPubPkg, 23 MetadataType: pkg.DartPubMetadataType, 24 Metadata: pkg.DartPubMetadata{ 25 Name: "ale", 26 Version: "3.3.0", 27 HostedURL: "pub.hosted.org", 28 }, 29 }, 30 { 31 Name: "analyzer", 32 Version: "0.40.7", 33 PURL: "pkg:pub/analyzer@0.40.7", 34 Locations: fixtureLocationSet, 35 Language: pkg.Dart, 36 Type: pkg.DartPubPkg, 37 MetadataType: pkg.DartPubMetadataType, 38 Metadata: pkg.DartPubMetadata{ 39 Name: "analyzer", 40 Version: "0.40.7", 41 }, 42 }, 43 { 44 Name: "ansicolor", 45 Version: "1.1.1", 46 PURL: "pkg:pub/ansicolor@1.1.1", 47 Locations: fixtureLocationSet, 48 Language: pkg.Dart, 49 Type: pkg.DartPubPkg, 50 MetadataType: pkg.DartPubMetadataType, 51 Metadata: pkg.DartPubMetadata{ 52 Name: "ansicolor", 53 Version: "1.1.1", 54 }, 55 }, 56 { 57 Name: "archive", 58 Version: "2.0.13", 59 PURL: "pkg:pub/archive@2.0.13", 60 Locations: fixtureLocationSet, 61 Language: pkg.Dart, 62 Type: pkg.DartPubPkg, 63 MetadataType: pkg.DartPubMetadataType, 64 Metadata: pkg.DartPubMetadata{ 65 Name: "archive", 66 Version: "2.0.13", 67 }, 68 }, 69 { 70 Name: "args", 71 Version: "1.6.0", 72 PURL: "pkg:pub/args@1.6.0", 73 Locations: fixtureLocationSet, 74 Language: pkg.Dart, 75 Type: pkg.DartPubPkg, 76 MetadataType: pkg.DartPubMetadataType, 77 Metadata: pkg.DartPubMetadata{ 78 Name: "args", 79 Version: "1.6.0", 80 }, 81 }, 82 { 83 Name: "flutter", 84 Version: "0.0.0", 85 PURL: "pkg:pub/flutter@0.0.0", 86 Locations: fixtureLocationSet, 87 Language: pkg.Dart, 88 Type: pkg.DartPubPkg, 89 MetadataType: pkg.DartPubMetadataType, 90 Metadata: pkg.DartPubMetadata{ 91 Name: "flutter", 92 Version: "0.0.0", 93 }, 94 }, 95 { 96 Name: "key_binder", 97 Version: "1.11.20", 98 PURL: "pkg:pub/key_binder@1.11.20?vcs_url=git%40github.com:Workiva/key_binder.git%403f7b3a6350e73c7dcac45301c0e18fbd42af02f7", 99 Locations: fixtureLocationSet, 100 Language: pkg.Dart, 101 Type: pkg.DartPubPkg, 102 MetadataType: pkg.DartPubMetadataType, 103 Metadata: pkg.DartPubMetadata{ 104 Name: "key_binder", 105 Version: "1.11.20", 106 VcsURL: "git@github.com:Workiva/key_binder.git@3f7b3a6350e73c7dcac45301c0e18fbd42af02f7", 107 }, 108 }, 109 } 110 111 // TODO: relationships are not under test 112 var expectedRelationships []artifact.Relationship 113 114 pkgtest.TestFileParser(t, fixture, parsePubspecLock, expected, expectedRelationships) 115 }