github.com/moby/docker@v26.1.3+incompatible/pkg/parsers/operatingsystem/windows_os_string_test.go (about)

     1  package operatingsystem
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func Test_windowsOSRelease_String(t *testing.T) {
     8  	tests := []struct {
     9  		name string
    10  		r    windowsOSRelease
    11  		want string
    12  	}{
    13  		{
    14  			name: "Flavor=client/DisplayVersion=yes/UBR=yes",
    15  			r: windowsOSRelease{
    16  				DisplayVersion: "1809",
    17  				Build:          17763,
    18  				UBR:            2628,
    19  			},
    20  			want: "Microsoft Windows Version 1809 (OS Build 17763.2628)",
    21  		},
    22  		{
    23  			name: "Flavor=client/DisplayVersion=yes/UBR=no",
    24  			r: windowsOSRelease{
    25  				DisplayVersion: "1809",
    26  				Build:          17763,
    27  			},
    28  			want: "Microsoft Windows Version 1809 (OS Build 17763)",
    29  		},
    30  		{
    31  			name: "Flavor=client/DisplayVersion=no/UBR=yes",
    32  			r: windowsOSRelease{
    33  				Build: 17763,
    34  				UBR:   1879,
    35  			},
    36  			want: "Microsoft Windows (OS Build 17763.1879)",
    37  		},
    38  		{
    39  			name: "Flavor=client/DisplayVersion=no/UBR=no",
    40  			r: windowsOSRelease{
    41  				Build: 10240,
    42  			},
    43  			want: "Microsoft Windows (OS Build 10240)",
    44  		},
    45  		{
    46  			name: "Flavor=server/DisplayVersion=yes/UBR=yes",
    47  			r: windowsOSRelease{
    48  				IsServer:       true,
    49  				DisplayVersion: "21H2",
    50  				Build:          20348,
    51  				UBR:            169,
    52  			},
    53  			want: "Microsoft Windows Server Version 21H2 (OS Build 20348.169)",
    54  		},
    55  		{
    56  			name: "Flavor=server/DisplayVersion=yes/UBR=no",
    57  			r: windowsOSRelease{
    58  				IsServer:       true,
    59  				DisplayVersion: "20H2",
    60  				Build:          19042,
    61  			},
    62  			want: "Microsoft Windows Server Version 20H2 (OS Build 19042)",
    63  		},
    64  		{
    65  			name: "Flavor=server/DisplayVersion=no/UBR=yes",
    66  			r: windowsOSRelease{
    67  				IsServer: true,
    68  				Build:    17763,
    69  				UBR:      107,
    70  			},
    71  			want: "Microsoft Windows Server (OS Build 17763.107)",
    72  		},
    73  		{
    74  			name: "Flavor=server/DisplayVersion=no/UBR=no",
    75  			r: windowsOSRelease{
    76  				IsServer: true,
    77  				Build:    17763,
    78  			},
    79  			want: "Microsoft Windows Server (OS Build 17763)",
    80  		},
    81  	}
    82  	for _, tt := range tests {
    83  		t.Run(tt.name, func(t *testing.T) {
    84  			if got := tt.r.String(); got != tt.want {
    85  				t.Errorf("windowsOSRelease.String() = %v, want %v", got, tt.want)
    86  			}
    87  		})
    88  	}
    89  }