mirror of https://github.com/helm/helm.git
Adding squote test case and generic message
This commit is contained in:
parent
59806b40a8
commit
d1fe406478
|
|
@ -129,7 +129,7 @@ func validateQuotes(templateName string, templateContent string) (lintError supp
|
|||
for _, str := range functions {
|
||||
if match, _ := regexp.MatchString("quote", str); !match {
|
||||
result := strings.Replace(str, "}}", " | quote }}", -1)
|
||||
lintError = fmt.Errorf("templates: \"%s\". add \"| quote\" to your substitution functions: %s -> %s", templateName, str, result)
|
||||
lintError = fmt.Errorf("templates: \"%s\". Wrap your substitution functions in quotes or use the sprig \"quote\" function: %s -> %s", templateName, str, result)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ func validateQuotes(templateName string, templateContent string) (lintError supp
|
|||
|
||||
for _, str := range functions {
|
||||
result := strings.Replace(str, str, fmt.Sprintf("\"%s\"", str), -1)
|
||||
lintError = fmt.Errorf("templates: \"%s\". wrap your substitution functions in double quotes: %s -> %s", templateName, str, result)
|
||||
lintError = fmt.Errorf("templates: \"%s\". Wrap your substitution functions in quotes: %s -> %s", templateName, str, result)
|
||||
return
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -47,12 +47,12 @@ func TestValidateQuotes(t *testing.T) {
|
|||
|
||||
for _, test := range failTest {
|
||||
err := validateQuotes("testTemplate.yaml", test)
|
||||
if err == nil || !strings.Contains(err.Error(), "add \"| quote\" to your substitution functions") {
|
||||
t.Errorf("validateQuotes('%s') to return \"add | quote error\", got no error", test)
|
||||
if err == nil || !strings.Contains(err.Error(), "use the sprig \"quote\" function") {
|
||||
t.Errorf("validateQuotes('%s') to return \"use the sprig \"quote\" function:\", got no error.", test)
|
||||
}
|
||||
}
|
||||
|
||||
var successTest = []string{"foo: {{.Release.Service | quote }}", "foo: {{.Release.Service | quote }}", "- {{.Release.Service | quote }}", "foo: {{default 'Never' .restart_policy | quote }}", "foo: \"{{ .Release.Service }}\"", "foo: \"{{ .Release.Service }} {{ .Foo.Bar }}\"", "foo: \"{{ default 'Never' .Release.Service }} {{ .Foo.Bar }}\""}
|
||||
var successTest = []string{"foo: {{.Release.Service | quote }}", "foo: {{.Release.Service | quote }}", "- {{.Release.Service | quote }}", "foo: {{default 'Never' .restart_policy | quote }}", "foo: \"{{ .Release.Service }}\"", "foo: \"{{ .Release.Service }} {{ .Foo.Bar }}\"", "foo: \"{{ default 'Never' .Release.Service }} {{ .Foo.Bar }}\"", "foo: {{.Release.Service | squote }}"}
|
||||
|
||||
for _, test := range successTest {
|
||||
err := validateQuotes("testTemplate.yaml", test)
|
||||
|
|
@ -66,8 +66,8 @@ func TestValidateQuotes(t *testing.T) {
|
|||
|
||||
for _, test := range failTest {
|
||||
err := validateQuotes("testTemplate.yaml", test)
|
||||
if err == nil || !strings.Contains(err.Error(), "wrap your substitution functions in double quotes") {
|
||||
t.Errorf("validateQuotes('%s') to return \"wrap your substitution functions in double quotes\", got no error %s", test, err.Error())
|
||||
if err == nil || !strings.Contains(err.Error(), "Wrap your substitution functions in quotes") {
|
||||
t.Errorf("validateQuotes('%s') to return \"Wrap your substitution functions in quotes\", got no error", test)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue