github.com/secure-build/gitlab-runner@v12.5.0+incompatible/helpers/dns/utils_test.go (about)

     1  package dns
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"gitlab.com/gitlab-org/gitlab-runner/helpers/dns/test"
     9  )
    10  
    11  func TestMakeRFC1123Compatible(t *testing.T) {
    12  	examples := []struct {
    13  		name     string
    14  		expected string
    15  	}{
    16  		{name: "tOk3_?ofTHE-Runner", expected: "tok3ofthe-runner"},
    17  		{name: "----tOk3_?ofTHE-Runner", expected: "tok3ofthe-runner"},
    18  		{name: "very-long-token-----------------------------------------------end", expected: "very-long-token-----------------------------------------------e"},
    19  	}
    20  
    21  	for _, example := range examples {
    22  		t.Run(example.name, func(t *testing.T) {
    23  			name := MakeRFC1123Compatible(example.name)
    24  
    25  			assert.Equal(t, example.expected, name)
    26  			test.AssertRFC1123Compatibility(t, name)
    27  		})
    28  	}
    29  }