github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/clusterid_test.go (about)

     1  package installconfig
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_generateInfraID(t *testing.T) {
    10  	tests := []struct {
    11  		input string
    12  
    13  		expLen     int
    14  		expNonRand string
    15  	}{{
    16  		input:      "qwertyuiop",
    17  		expLen:     10 + randomLen + 1,
    18  		expNonRand: "qwertyuiop",
    19  	}, {
    20  		input:      "qwertyuiopasdfghjklzxcvbnm",
    21  		expLen:     27,
    22  		expNonRand: "qwertyuiopasdfghjklzx",
    23  	}, {
    24  		input:      "qwertyuiopasdfghjklz-cvbnm",
    25  		expLen:     26,
    26  		expNonRand: "qwertyuiopasdfghjklz",
    27  	}, {
    28  		input:      "qwe.rty.@iop!",
    29  		expLen:     11 + randomLen + 1,
    30  		expNonRand: "qwe-rty-iop",
    31  	}}
    32  	for _, test := range tests {
    33  		t.Run("", func(t *testing.T) {
    34  			got := generateInfraID(test.input, 27)
    35  			t.Log("InfraID", got)
    36  			assert.Equal(t, test.expLen, len(got))
    37  			assert.Equal(t, test.expNonRand, got[:len(got)-randomLen-1])
    38  		})
    39  	}
    40  }