@@ -487,3 +487,69 @@ func TestCreatePackage(t *testing.T) {
487487 assert .Equal (t , "GDR 2042 für SQL Server 2017 (KB5014354) (64-bit)" , pkg .Name )
488488 })
489489}
490+
491+ func TestFindAndUpdateMsExchangeSU_en (t * testing.T ) {
492+ // Setup: create a list of packages with Exchange CU and SU
493+ packages := []Package {
494+ // This is the version of the latest CU installed on the machine
495+ {Name : "Microsoft Exchange Server" , Version : "15.2.1748.10" , PUrl : "pkg:windows/windows/Microsoft%20Exchange%20Server@15.2.1748.10?arch=AMD64" },
496+ // This is a SU for the CU and updates only the CU version, not the main Exchange Server version
497+ {Name : "Security Update for Exchange Server 2019 Cumulative Update 15 (KB5063221)" , Version : "1" , PUrl : "pkg:windows/windows/Security%20Update%20for%20Exchange%20Server%202019%20Cumulative%20Update%2015%20%28KB5063221%29@1?arch=AMD64" },
498+ // We need this version
499+ {Name : "Microsoft Exchange Server 2019 Cumulative Update 15" , Version : "15.2.1748.36" , PUrl : "pkg:windows/windows/Microsoft%20Exchange%20Server%202019%20Cumulative%20Update%2015@15.2.1748.36?arch=AMD64" },
500+ {Name : "Not a hotfix" , Version : "1.0.0" , PUrl : "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" },
501+ }
502+
503+ expectedLatestVersion := "15.2.1748.36"
504+ // Step 1: Find SQL Server hotfixes
505+ cu := findExchangeCU (packages )
506+ require .NotNil (t , cu )
507+
508+ // Step 2: Update SQL Server packages with the latest hotfix version
509+ updated := updateExchangePackage (packages , * cu )
510+
511+ // Step 3: Check that the Exchange Server package has the updated version
512+ pkg := findPkgByName (updated , "Microsoft Exchange Server" )
513+ require .NotNil (t , pkg )
514+ require .Equal (t , expectedLatestVersion , pkg .Version )
515+ assert .Equal (t , "pkg:windows/windows/Microsoft%20Exchange%20Server@" + expectedLatestVersion + "?arch=AMD64" , pkg .PUrl )
516+
517+ // Step 5: Ensure non-SQL Server packages are unchanged
518+ pkg = findPkgByName (updated , "Not a hotfix" )
519+ require .NotNil (t , pkg )
520+ require .Equal (t , "1.0.0" , pkg .Version )
521+ assert .Equal (t , "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" , pkg .PUrl )
522+ }
523+
524+ func TestFindAndUpdateMsExchangeSU_de (t * testing.T ) {
525+ // Setup: create a list of packages with Exchange CU and SU
526+ packages := []Package {
527+ // This is the version of the latest CU installed on the machine
528+ {Name : "Microsoft Exchange Server" , Version : "15.2.1748.10" , PUrl : "pkg:windows/windows/Microsoft%20Exchange%20Server@15.2.1748.10?arch=AMD64" },
529+ // This is a SU for the CU and updates only the CU version, not the main Exchange Server version
530+ {Name : "Security Update für Exchange Server 2019 Kumulatives Update 15 (KB5063221)" , Version : "1" , PUrl : "pkg:windows/windows/Security%20Update%20f%C3%BCr%20Exchange%20Server%202019%20Kumulatives%20Update%2015%20%28KB5063221%29@1?arch=AMD64" },
531+ // We need this version
532+ {Name : "Microsoft Exchange Server 2019 Kumulatives Update 15" , Version : "15.2.1748.36" , PUrl : "pkg:windows/windows/Microsoft%20Exchange%20Server%202019%20Kumulatives%20Update%2015@15.2.1748.36?arch=AMD64" },
533+ {Name : "Not a hotfix" , Version : "1.0.0" , PUrl : "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" },
534+ }
535+
536+ expectedLatestVersion := "15.2.1748.36"
537+ // Step 1: Find SQL Server hotfixes
538+ cu := findExchangeCU (packages )
539+ require .NotNil (t , cu )
540+
541+ // Step 2: Update SQL Server packages with the latest hotfix version
542+ updated := updateExchangePackage (packages , * cu )
543+
544+ // Step 3: Check that the Exchange Server package has the updated version
545+ pkg := findPkgByName (updated , "Microsoft Exchange Server" )
546+ require .NotNil (t , pkg )
547+ require .Equal (t , expectedLatestVersion , pkg .Version )
548+ assert .Equal (t , "pkg:windows/windows/Microsoft%20Exchange%20Server@" + expectedLatestVersion + "?arch=AMD64" , pkg .PUrl )
549+
550+ // Step 5: Ensure non-SQL Server packages are unchanged
551+ pkg = findPkgByName (updated , "Not a hotfix" )
552+ require .NotNil (t , pkg )
553+ require .Equal (t , "1.0.0" , pkg .Version )
554+ assert .Equal (t , "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" , pkg .PUrl )
555+ }
0 commit comments