github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/util.go (about) 1 package fixture 2 3 import ( 4 "regexp" 5 "strings" 6 "testing" 7 8 "github.com/stretchr/testify/require" 9 10 "golang.org/x/sync/errgroup" 11 ) 12 13 var ( 14 matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)") 15 matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])") 16 ) 17 18 // returns dns friends string which is no longer than 63 characters and has specified postfix at the end 19 func DnsFriendly(str string, postfix string) string { //nolint:revive //FIXME(var-naming) 20 str = matchFirstCap.ReplaceAllString(str, "${1}-${2}") 21 str = matchAllCap.ReplaceAllString(str, "${1}-${2}") 22 str = strings.ToLower(str) 23 24 if diff := len(str) + len(postfix) - 63; diff > 0 { 25 str = str[:len(str)-diff] 26 } 27 return str + postfix 28 } 29 30 func RunFunctionsInParallelAndCheckErrors(t *testing.T, functions []func() error) { 31 t.Helper() 32 var eg errgroup.Group 33 for _, function := range functions { 34 eg.Go(function) 35 } 36 require.NoError(t, eg.Wait()) 37 }