gitlab.com/jfprevost/gitlab-runner-notlscheck@v11.11.4+incompatible/helpers/docker/helperimage/info_test.go (about)

     1  package helperimage
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"gitlab.com/gitlab-org/gitlab-runner/helpers/docker/errors"
     9  )
    10  
    11  func TestGetInfo(t *testing.T) {
    12  	tests := []struct {
    13  		osType                  string
    14  		expectedHelperImageType interface{}
    15  		expectedError           interface{}
    16  	}{
    17  		{osType: OSTypeLinux, expectedError: nil},
    18  		{osType: OSTypeWindows, expectedError: ErrUnsupportedOSVersion},
    19  		{osType: "unsupported", expectedError: errors.NewErrOSNotSupported("unsupported")},
    20  	}
    21  
    22  	for _, test := range tests {
    23  		t.Run(test.osType, func(t *testing.T) {
    24  			_, err := Get(headRevision, Config{OSType: test.osType})
    25  
    26  			assert.Equal(t, test.expectedError, err)
    27  		})
    28  	}
    29  }
    30  
    31  func TestContainerImage_String(t *testing.T) {
    32  	image := Info{
    33  		Name: "abc",
    34  		Tag:  "1234",
    35  	}
    36  
    37  	assert.Equal(t, "abc:1234", image.String())
    38  }
    39  
    40  func Test_imageRevision(t *testing.T) {
    41  	tests := []struct {
    42  		revision    string
    43  		expectedTag string
    44  	}{
    45  		{
    46  			revision:    headRevision,
    47  			expectedTag: latestImageRevision,
    48  		},
    49  		{
    50  			revision:    "1234",
    51  			expectedTag: "1234",
    52  		},
    53  	}
    54  
    55  	for _, test := range tests {
    56  		t.Run(test.revision, func(t *testing.T) {
    57  			assert.Equal(t, test.expectedTag, imageRevision(test.revision))
    58  		})
    59  	}
    60  
    61  }