@@ -1565,3 +1565,67 @@ func TestRiskManagementHelp(t *testing.T) {
15651565func TestRiskManagement (t * testing.T ) {
15661566 execCmdNilAssertion (t , "results" , "risk-management" )
15671567}
1568+
1569+ func Test_addPackageInformation_DependencyTypes (t * testing.T ) {
1570+ // Create dependency paths with different types
1571+ var dependencyPaths = [][]wrappers.DependencyPath {
1572+ {{
1573+ ID : "dev-pkg" ,
1574+ IsDevelopment : true ,
1575+ }},
1576+ {{
1577+ ID : "test-pkg" ,
1578+ IsDevelopment : false ,
1579+ }},
1580+ }
1581+
1582+ // Create results model with two results - one dev and one test
1583+ resultsModel := & wrappers.ScanResultsCollection {
1584+ Results : []* wrappers.ScanResult {
1585+ {
1586+ Type : "sca" ,
1587+ ScanResultData : wrappers.ScanResultData {
1588+ PackageIdentifier : "dev-pkg" ,
1589+ },
1590+ },
1591+ {
1592+ Type : "sca" ,
1593+ ScanResultData : wrappers.ScanResultData {
1594+ PackageIdentifier : "test-pkg" ,
1595+ },
1596+ },
1597+ },
1598+ }
1599+
1600+ // Create package model with different dev/test settings
1601+ scaPackageModel := & []wrappers.ScaPackageCollection {
1602+ {
1603+ ID : "dev-pkg" ,
1604+ DependencyPathArray : dependencyPaths [:1 ],
1605+ IsDevelopmentDependency : true ,
1606+ IsTestDependency : false ,
1607+ },
1608+ {
1609+ ID : "test-pkg" ,
1610+ DependencyPathArray : dependencyPaths [1 :],
1611+ IsDevelopmentDependency : false ,
1612+ IsTestDependency : true ,
1613+ },
1614+ }
1615+
1616+ scaTypeModel := & []wrappers.ScaTypeCollection {{}}
1617+
1618+ // Execute the function
1619+ resultsModel = addPackageInformation (resultsModel , scaPackageModel , scaTypeModel )
1620+
1621+ // Get the results
1622+ devPackage := resultsModel .Results [0 ].ScanResultData .ScaPackageCollection
1623+ testPackage := resultsModel .Results [1 ].ScanResultData .ScaPackageCollection
1624+
1625+ // Verify the fields were transferred correctly
1626+ assert .Equal (t , true , devPackage .IsDevelopmentDependency , "First package should be marked as development dependency" )
1627+ assert .Equal (t , false , devPackage .IsTestDependency , "First package should not be marked as test dependency" )
1628+
1629+ assert .Equal (t , false , testPackage .IsDevelopmentDependency , "Second package should not be marked as development dependency" )
1630+ assert .Equal (t , true , testPackage .IsTestDependency , "Second package should be marked as test dependency" )
1631+ }
0 commit comments