github.com/kubeshop/testkube@v1.17.23/pkg/storage/minio/minio_test.go (about)

     1  package minio
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestGetBucketName(t *testing.T) {
    10  	t.Parallel()
    11  
    12  	tests := []struct {
    13  		name         string
    14  		parentName   string
    15  		parentType   string
    16  		expectedName string
    17  	}{
    18  		{
    19  			name:         "bucket name is less than 63 chars",
    20  			parentName:   "testName",
    21  			parentType:   "test",
    22  			expectedName: "test-testName",
    23  		},
    24  		{
    25  			name:         "bucket name is 63 chars",
    26  			parentName:   "O7s7A6qyDqtHO6kBDPOjQms0Mgom5P7IQx2W68BAET2Sox00EwMTeJVs1V",
    27  			parentType:   "test",
    28  			expectedName: "test-O7s7A6qyDqtHO6kBDPOjQms0Mgom5P7IQx2W68BAET2Sox00EwMTeJVs1V",
    29  		},
    30  		{
    31  			name: "bucket name is over 63 chars",
    32  			parentName: "O7s7A6qyDqtHO6kBDPOjQms0Mgom5P7IQx2W68BAET2Sox00EwMTeJVs1V" +
    33  				"O7s7A6qyDqtHO6kBDPOjQms0Mgom5P7IQx2W68BAET2Sox00EwMTeJVs1V",
    34  			parentType:   "test",
    35  			expectedName: "test-O7s7A6qyDqtHO6kBDPOjQms0Mgom5P7IQx2W68BAET2Sox0-3877779712",
    36  		},
    37  	}
    38  	var c Client
    39  	for i := range tests {
    40  		tt := tests[i]
    41  		t.Run(tt.name, func(t *testing.T) {
    42  			t.Parallel()
    43  			actualName := c.GetValidBucketName(tt.parentType, tt.parentName)
    44  			assert.Equal(t, tt.expectedName, actualName)
    45  			assert.LessOrEqual(t, len(actualName), 63)
    46  		})
    47  	}
    48  }