github.com/nilium/gitlab-runner@v12.5.0+incompatible/helpers/dns/test/test.go (about)

     1  package test
     2  
     3  import (
     4  	"regexp"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func AssertRFC1123Compatibility(t *testing.T, name string) {
    11  	dns1123MaxLength := 63
    12  	dns1123FormatRegexp := regexp.MustCompile("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
    13  
    14  	assert.True(t, len(name) <= dns1123MaxLength, "Name length needs to be shorter than %d", dns1123MaxLength)
    15  	assert.Regexp(t, dns1123FormatRegexp, name, "Name needs to be in RFC-1123 allowed format")
    16  }