Skip to content

Commit 556f9ed

Browse files
committed
fix(require): correct CollectT references in comments
Update require package comments and templates to reference assert.CollectT instead of require.CollectT, ensuring consistency and correctness in documentation and generated code. Also refactor template function usage to centralize string replacement logic. Signed-off-by: a2not <31874975+a2not@users.noreply.github.com>
1 parent aaef048 commit 556f9ed

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

_codegen/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ func parseTemplates() (*template.Template, *template.Template, error) {
106106
}
107107
funcTemplate = string(f)
108108
}
109-
tmpl, err := template.New("function").Funcs(template.FuncMap{
110-
"replace": strings.ReplaceAll,
111-
}).Parse(funcTemplate)
109+
tmpl, err := template.New("function").Parse(funcTemplate)
112110
if err != nil {
113111
return nil, nil, err
114112
}
@@ -331,6 +329,8 @@ func requireComment(comment string) string {
331329

332330
func (f *testFunc) CommentRequire() string {
333331
comment := strings.ReplaceAll(f.DocInfo.Doc, "assert.", "require.")
332+
// Preserve assert.CollectT, even in package 'require'
333+
comment = strings.ReplaceAll(comment, "require.CollectT", "assert.CollectT")
334334
return requireComment(comment)
335335
}
336336

require/require.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
429429
// time.Sleep(8*time.Second)
430430
// externalValue = true
431431
// }()
432-
// require.EventuallyWithT(t, func(c *require.CollectT) {
432+
// require.EventuallyWithT(t, func(c *assert.CollectT) {
433433
// // add assertions as needed; any assertion failure will fail the current tick
434434
// require.True(c, externalValue, "expected 'externalValue' to be true")
435435
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
@@ -457,7 +457,7 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF
457457
// time.Sleep(8*time.Second)
458458
// externalValue = true
459459
// }()
460-
// require.EventuallyWithTf(t, func(c *require.CollectT, "error message %s", "formatted") {
460+
// require.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
461461
// // add assertions as needed; any assertion failure will fail the current tick
462462
// require.True(c, externalValue, "expected 'externalValue' to be true")
463463
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")

0 commit comments

Comments
 (0)