@@ -528,6 +528,82 @@ func TestParseYarnLockWithRelationships(t *testing.T) {
528528 adapter := newGenericYarnLockAdapter (CatalogerConfig {})
529529 pkgtest .TestFileParser (t , fixture , adapter .parseYarnLock , expectedPkgs , expectedRelationships )
530530}
531+ func TestParseYarnLockWithDuplicates (t * testing.T ) {
532+ var expectedRelationships []artifact.Relationship
533+ fixture := "test-fixtures/yarn-dups/yarn.lock"
534+ locations := file .NewLocationSet (file .NewLocation (fixture ))
535+
536+ expectedPkgs := []pkg.Package {
537+ {
538+ Name : "async" ,
539+ Version : "0.9.2" ,
540+ Locations : locations ,
541+ PURL :
"pkg:npm/[email protected] " ,
542+ Language : pkg .JavaScript ,
543+ Type : pkg .NpmPkg ,
544+ Metadata : pkg.YarnLockEntry {
545+ Resolved : "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" ,
546+ Integrity : "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" ,
547+ Dependencies : map [string ]string {},
548+ },
549+ },
550+ {
551+ Name : "async" ,
552+ Version : "3.2.3" ,
553+ Locations : locations ,
554+ PURL :
"pkg:npm/[email protected] " ,
555+ Language : pkg .JavaScript ,
556+ Type : pkg .NpmPkg ,
557+ Metadata : pkg.YarnLockEntry {
558+ Resolved : "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9" ,
559+ Integrity : "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" ,
560+ Dependencies : map [string ]string {},
561+ },
562+ },
563+ {
564+ Name : "merge-objects" ,
565+ Version : "1.0.5" ,
566+ Locations : locations ,
567+ PURL :
"pkg:npm/[email protected] " ,
568+ Language : pkg .JavaScript ,
569+ Type : pkg .NpmPkg ,
570+ Metadata : pkg.YarnLockEntry {
571+ Resolved : "https://registry.yarnpkg.com/merge-objects/-/merge-objects-1.0.5.tgz#ad923ff3910091acc1438f53eb75b8f37d862a86" ,
572+ Integrity : "sha1-rZI/85EAkazBQ49T63W4832GKoY=" ,
573+ Dependencies : map [string ]string {},
574+ },
575+ },
576+ {
577+ Name : "@4lolo/resize-observer-polyfill" ,
578+ Version : "1.5.2" ,
579+ Locations : locations ,
580+ PURL :
"pkg:npm/%404lolo/[email protected] " ,
581+ Language : pkg .JavaScript ,
582+ Type : pkg .NpmPkg ,
583+ Metadata : pkg.YarnLockEntry {
584+ Resolved : "https://registry.yarnpkg.com/@4lolo/resize-observer-polyfill/-/resize-observer-polyfill-1.5.2.tgz#58868fc7224506236b5550d0c68357f0a874b84b" ,
585+ Integrity : "sha512-HY4JYLITsWBOdeqCF/x3q7Aa2PVl/BmfkPv4H/Qzplc4Lrn9cKmWz6jHyAREH9tFuD0xELjJVgX3JaEmdcXu3g==" ,
586+ Dependencies : map [string ]string {},
587+ },
588+ },
589+ {
590+ Name : "should-type" ,
591+ Version : "1.3.0" ,
592+ Locations : locations ,
593+ PURL :
"pkg:npm/[email protected] " ,
594+ Language : pkg .JavaScript ,
595+ Type : pkg .NpmPkg ,
596+ Metadata : pkg.YarnLockEntry {
597+ Resolved : "https://github.com/shouldjs/type.git#31d26945cb3b4ad21d2308776e4442c461666390" ,
598+ Integrity : "" ,
599+ Dependencies : map [string ]string {},
600+ },
601+ },
602+ }
603+
604+ adapter := newGenericYarnLockAdapter (CatalogerConfig {})
605+ pkgtest .TestFileParser (t , fixture , adapter .parseYarnLock , expectedPkgs , expectedRelationships )
606+ }
531607
532608type handlerPath struct {
533609 path string
0 commit comments