github.com/argoproj/argo-cd/v3@v3.2.1/test/e2e/fixture/tmpl.go (about) 1 package fixture 2 3 import ( 4 "bytes" 5 "regexp" 6 "strings" 7 "testing" 8 "text/template" 9 10 "github.com/stretchr/testify/require" 11 ) 12 13 // utility method to template a string using a map 14 func Tmpl(t *testing.T, text string, values any) string { 15 t.Helper() 16 parse, err := template.New(text).Parse(text) 17 require.NoError(t, err) 18 buf := new(bytes.Buffer) 19 err = parse.Execute(buf, values) 20 require.NoError(t, err) 21 return buf.String() 22 } 23 24 // utility method to deal with white-space 25 func NormalizeOutput(text string) string { 26 return regexp.MustCompile(` +`). 27 ReplaceAllString(strings.TrimSpace(text), " ") 28 }