@@ -490,8 +490,8 @@ func TestFindAndUpdateMsSqlGDR_de(t *testing.T) {
490490 {Name : "SQL Server 2022 Shared Management Objects" , Version : "16.0.1050.5" , PUrl : "pkg:windows/windows/SQL%20Server%202022%20Shared%20Management%20Objects@16.0.1050.5?arch=x86" },
491491 // We should not update the setup package
492492 {Name : "Microsoft SQL Server 2022 Setup (English)" , Version : "16.0.1050.5" , PUrl : "pkg:windows/windows/Microsoft%20SQL%20Server%202022%20Setup%20%28English%29@16.0.1050.5?arch=x86" },
493- {Name : "GDR 1115 für SQL Server 2022 (KB5035432) (64-bit)" , Version : "16.0.1115.1" , PUrl : "pkg:windows/windows/GDR%201115%20für %20SQL%20Server%202022%20%28KB5035432%29%20%2864-bit%29@16.0.1115.1?arch=x86" },
494- {Name : "GDR 1110 für SQL Server 2022 (KB5032968) (64-bit)" , Version : "16.0.1110.1" , PUrl : "pkg:windows/windows/GDR%201110%20für %20SQL%20Server%202022%20%28KB5032968%29%20%2864-bit%29@16.0.1110.1?arch=x86" },
493+ {Name : "GDR 1115 für SQL Server 2022 (KB5035432) (64-bit)" , Version : "16.0.1115.1" , PUrl : "pkg:windows/windows/GDR%201115%20f%C3%BCr %20SQL%20Server%202022%20%28KB5035432%29%20%2864-bit%29@16.0.1115.1?arch=x86" },
494+ {Name : "GDR 1110 für SQL Server 2022 (KB5032968) (64-bit)" , Version : "16.0.1110.1" , PUrl : "pkg:windows/windows/GDR%201110%20f%C3%BCr %20SQL%20Server%202022%20%28KB5032968%29%20%2864-bit%29@16.0.1110.1?arch=x86" },
495495 {Name : "Not a hotfix" , Version : "1.0.0" , PUrl : "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" },
496496 }
497497
@@ -527,3 +527,62 @@ func TestFindAndUpdateMsSqlGDR_de(t *testing.T) {
527527 require .Equal (t , "1.0.0" , pkg .Version , "expected non-SQL Server package to remain unchanged" )
528528 assert .Equal (t , "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" , pkg .PUrl )
529529}
530+
531+ func TestFindAndUpdateMsSqlGDR_de_special_characters (t * testing.T ) {
532+ // Setup: create a list of packages with SQL Server hotfixes and SQL Server packages
533+ packages := []Package {
534+ {Name : "SQL Server 2017 Database Engine Services" , Version : "14.0.1000.169" , PUrl : "pkg:windows/windows/SQL%20Server%202017%20Database%20Engine%20Services@14.0.1000.169?arch=x86" },
535+ {Name : "SQL Server 2017 Shared Management Objects" , Version : "14.0.1000.169" , PUrl : "pkg:windows/windows/SQL%20Server%202022%20Shared%20Management%20Objects@14.0.1000.169?arch=x86" },
536+ // We should not update the setup package
537+ {Name : "Microsoft SQL Server 2017 Setup (English)" , Version : "14.0.1000.169" , PUrl : "pkg:windows/windows/Microsoft%20SQL%20Server%202017%20Setup%20%28English%29@14.0.1050.5" },
538+ // This package contains a non breaking space between SQL Server and 2017
539+ {Name : "GDR 2042 für SQL Server 2017 (KB5014354) (64-bit)" , Version : "14.0.2042.3" , PUrl : "pkg:windows/windows/GDR%202042%20f%C3%BCr%20SQL%20Server%202017%20%28KB5014354%29%20%2864-bit%29@14.0.2042.3?arch=x86" },
540+ // This package contains a non breaking space between SQL Server and 2017
541+ {Name : "GDR 2037 für SQL Server 2017 (KB4583456) (64-bit)" , Version : "14.0.2037.2" , PUrl : "pkg:windows/windows/GDR%202037%20f%C3%BCr%20SQL%20Server%202017%20%28KB4583456%29%20%2864-bit%29@14.0.2037.2?arch=x86" },
542+ {Name : "Not a hotfix" , Version : "1.0.0" , PUrl : "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" },
543+ }
544+
545+ // Step 1: Find SQL Server gdrUpdates
546+ gdrUpdates := findMsSqlGdrUpdates (packages )
547+ require .Len (t , gdrUpdates , 2 , "expected 2 updates" )
548+
549+ // Step 2: Get the latest hotfix (should be the last one after sorting)
550+ latestUpdate := gdrUpdates [len (gdrUpdates )- 1 ]
551+ expectedLatestVersion := "14.0.2042.3"
552+ require .Equal (t , expectedLatestVersion , latestUpdate .Version , "expected latest update version" )
553+
554+ // Step 3: Update SQL Server packages with the latest hotfix version
555+ updated := updateMsSqlPackages (packages , latestUpdate )
556+
557+ // Step 4: Check that all SQL Server packages have the updated version
558+ pkg := findPkgByName (updated , "SQL Server 2017 Database Engine Services" )
559+ require .NotNil (t , pkg , "SQL Server 2017 Database Engine Services package should exist" )
560+ require .Equal (t , expectedLatestVersion , pkg .Version , "expected SQL Server 2017 Database Engine Services to have updated version" )
561+ assert .Equal (t , "pkg:windows/windows/SQL%20Server%202017%20Database%20Engine%20Services@14.0.2042.3?arch=x86" , pkg .PUrl )
562+
563+ // Step 5: Ensure non-SQL Server packages are unchanged
564+ pkg = findPkgByName (updated , "Not a hotfix" )
565+ require .NotNil (t , pkg , "Not a hotfix package should exist" )
566+ require .Equal (t , "1.0.0" , pkg .Version , "expected non-SQL Server package to remain unchanged" )
567+ assert .Equal (t , "pkg:windows/windows/Not%20a%20hotfix@1.0.0?arch=x86" , pkg .PUrl )
568+ }
569+
570+ func TestCreatePackage (t * testing.T ) {
571+ t .Run ("create package with non-breaking space in name" , func (t * testing.T ) {
572+ // The name contains a non-breaking space between Server and 2017
573+ pkg := createPackage ("GDR 2042 für SQL Server 2017 (KB5014354) (64-bit)" , "1234" , "windows/app" , "x86_64" , "Microsoft" , "" , nil )
574+ require .NotNil (t , pkg , "expected package to be created" )
575+
576+ // Here we check that the name is replaced with a regular space
577+ assert .Equal (t , "GDR 2042 für SQL Server 2017 (KB5014354) (64-bit)" , pkg .Name )
578+ })
579+
580+ t .Run ("create package with non-breaking space in name - unicode" , func (t * testing.T ) {
581+ // The name contains a non-breaking space between Server and 2017
582+ pkg := createPackage ("GDR 2042 für SQL Server\u00a0 2017 (KB5014354) (64-bit)" , "1234" , "windows/app" , "x86_64" , "Microsoft" , "" , nil )
583+ require .NotNil (t , pkg , "expected package to be created" )
584+
585+ // Here we check that the name is replaced with a regular space
586+ assert .Equal (t , "GDR 2042 für SQL Server 2017 (KB5014354) (64-bit)" , pkg .Name )
587+ })
588+ }
0 commit comments