github.com/secure-build/gitlab-runner@v12.5.0+incompatible/helpers/docker/helperimage/windows_info_test.go (about)

     1  package helperimage
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func Test_windowsInfo_create(t *testing.T) {
    11  	revision := "4011f186"
    12  	tests := []struct {
    13  		operatingSystem string
    14  		expectedInfo    Info
    15  		expectedErr     error
    16  	}{
    17  		{
    18  			operatingSystem: "Windows Server 2019 Datacenter Evaluation Version 1809 (OS Build 17763.316)",
    19  			expectedInfo: Info{
    20  				Architecture: windowsSupportedArchitecture,
    21  				Name:         name,
    22  				Tag:          fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1809),
    23  				IsSupportingLocalImport: false,
    24  				Cmd: powerShellCmd,
    25  			},
    26  			expectedErr: nil,
    27  		},
    28  		{
    29  			operatingSystem: "Windows Server Datacenter Version 1809 (OS Build 1803.590)",
    30  			expectedInfo: Info{
    31  				Architecture: windowsSupportedArchitecture,
    32  				Name:         name,
    33  				Tag:          fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1809),
    34  				IsSupportingLocalImport: false,
    35  				Cmd: powerShellCmd,
    36  			},
    37  			expectedErr: nil,
    38  		},
    39  		{
    40  			operatingSystem: "Windows Server Datacenter Version 1803 (OS Build 17134.590)",
    41  			expectedInfo: Info{
    42  				Architecture: windowsSupportedArchitecture,
    43  				Name:         name,
    44  				Tag:          fmt.Sprintf("%s-%s-%s", windowsSupportedArchitecture, revision, baseImage1803),
    45  				IsSupportingLocalImport: false,
    46  				Cmd: powerShellCmd,
    47  			},
    48  			expectedErr: nil,
    49  		},
    50  		{
    51  			operatingSystem: "some random string",
    52  			expectedErr:     ErrUnsupportedOSVersion,
    53  		},
    54  	}
    55  
    56  	for _, test := range tests {
    57  		t.Run(test.operatingSystem, func(t *testing.T) {
    58  			w := new(windowsInfo)
    59  
    60  			image, err := w.Create(revision, Config{OperatingSystem: test.operatingSystem})
    61  
    62  			assert.Equal(t, test.expectedInfo, image)
    63  			assert.Equal(t, test.expectedErr, err)
    64  		})
    65  	}
    66  }