Generate better comments for require package

The comments for the require package were just copied over
from the assert package when generating the functions.
This could lead to confusion because
1. The code-examples were showing examples using the
assert package instead of the require package
2. The function-documentation was not mentioning that
the functions were calling `t.FailNow()` which is some
critical information when using this package.
pull/1610/head
Simon Schulte 2024-06-13 06:52:14 +02:00
parent 1b4fca7679
commit 9326036bf5
3 changed files with 423 additions and 184 deletions

View File

@ -107,7 +107,9 @@ func parseTemplates() (*template.Template, *template.Template, error) {
}
funcTemplate = string(f)
}
tmpl, err := template.New("function").Parse(funcTemplate)
tmpl, err := template.New("function").Funcs(template.FuncMap{
"replace": strings.ReplaceAll,
}).Parse(funcTemplate)
if err != nil {
return nil, nil, err
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
{{.Comment}}
{{ replace .Comment "assert." "require."}}
// Instead of returning a boolean result this function calls `t.FailNow()` on failure.
func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
if h, ok := t.(tHelper); ok { h.Helper() }
if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }