Skip to content

Commit 101072d

Browse files
authored
Merge pull request #1821 from a2not/fix-doc-require_collect-not-exist
docs(require): correct example usage to use assert.CollectT (require.CollectT does not exist)
2 parents aaef048 + 556f9ed commit 101072d

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)