mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
9aacaeb667
Microsoft has stopped updating the ProductName registry value in Windows 11; it reads as Windows 10. And Microsoft has made it very difficult to look up the real product name programmatically so that applications do not attempt to parse it. (Ever wonder why they skipped Windows 9?) The only documented and supported mechanisms require WMI or WinRT. The product name has no bearing on application compatibility so it is not worth doing any heroics to display the correct name. The build number and Update Build Revision is sufficient information to identify a specific build of Windows. Stop displaying the ProductName so as not to confuse users with incorrect information. Microsoft has frozen the ReleaseId registry value at 2009 when they switched to semi-annual releases and alpha-numeric versions. The release version as displayed by winver.exe and Settings -> System -> About on Windows 20H2 and newer can be found in the new DisplayVersion registry value. Replicate the way winver.exe displays the version by preferentially reporting the DisplayVersion if present and reporting if it is a Windows Server edition. Signed-off-by: Cory Snider <csnider@mirantis.com>
89 lines
2 KiB
Go
89 lines
2 KiB
Go
package operatingsystem
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_windowsOSRelease_String(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
r windowsOSRelease
|
|
want string
|
|
}{
|
|
{
|
|
name: "Flavor=client/DisplayVersion=yes/UBR=yes",
|
|
r: windowsOSRelease{
|
|
DisplayVersion: "1809",
|
|
Build: 17763,
|
|
UBR: 2628,
|
|
},
|
|
want: "Microsoft Windows Version 1809 (OS Build 17763.2628)",
|
|
},
|
|
{
|
|
name: "Flavor=client/DisplayVersion=yes/UBR=no",
|
|
r: windowsOSRelease{
|
|
DisplayVersion: "1809",
|
|
Build: 17763,
|
|
},
|
|
want: "Microsoft Windows Version 1809 (OS Build 17763)",
|
|
},
|
|
{
|
|
name: "Flavor=client/DisplayVersion=no/UBR=yes",
|
|
r: windowsOSRelease{
|
|
Build: 17763,
|
|
UBR: 1879,
|
|
},
|
|
want: "Microsoft Windows (OS Build 17763.1879)",
|
|
},
|
|
{
|
|
name: "Flavor=client/DisplayVersion=no/UBR=no",
|
|
r: windowsOSRelease{
|
|
Build: 10240,
|
|
},
|
|
want: "Microsoft Windows (OS Build 10240)",
|
|
},
|
|
{
|
|
name: "Flavor=server/DisplayVersion=yes/UBR=yes",
|
|
r: windowsOSRelease{
|
|
IsServer: true,
|
|
DisplayVersion: "21H2",
|
|
Build: 20348,
|
|
UBR: 169,
|
|
},
|
|
want: "Microsoft Windows Server Version 21H2 (OS Build 20348.169)",
|
|
},
|
|
{
|
|
name: "Flavor=server/DisplayVersion=yes/UBR=no",
|
|
r: windowsOSRelease{
|
|
IsServer: true,
|
|
DisplayVersion: "20H2",
|
|
Build: 19042,
|
|
},
|
|
want: "Microsoft Windows Server Version 20H2 (OS Build 19042)",
|
|
},
|
|
{
|
|
name: "Flavor=server/DisplayVersion=no/UBR=yes",
|
|
r: windowsOSRelease{
|
|
IsServer: true,
|
|
Build: 17763,
|
|
UBR: 107,
|
|
},
|
|
want: "Microsoft Windows Server (OS Build 17763.107)",
|
|
},
|
|
{
|
|
name: "Flavor=server/DisplayVersion=no/UBR=no",
|
|
r: windowsOSRelease{
|
|
IsServer: true,
|
|
Build: 17763,
|
|
},
|
|
want: "Microsoft Windows Server (OS Build 17763)",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := tt.r.String(); got != tt.want {
|
|
t.Errorf("windowsOSRelease.String() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|