Skip to content

Commit f60ffea

Browse files
authored
fix: generated formatted variant should use variadic args (#116)
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent 04f252d commit f60ffea

14 files changed

Lines changed: 468 additions & 464 deletions

File tree

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ linters:
77
- funlen
88
- godox
99
- gomoddirectives
10+
- gomodguard
11+
- gomodguard_v2
1012
- exhaustruct
1113
- nlreturn
1214
- nonamedreturns
@@ -46,6 +48,7 @@ linters:
4648
- legacy
4749
- std-error-handling
4850
paths:
51+
- .worktrees
4952
- third_party$
5053
- builtin$
5154
- examples$
@@ -61,6 +64,7 @@ formatters:
6164
exclusions:
6265
generated: lax
6366
paths:
67+
- .worktrees
6468
- third_party$
6569
- builtin$
6670
- examples$

assert/assert_format.go

Lines changed: 137 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assert/assert_forward.go

Lines changed: 84 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codegen/internal/generator/templates/assertion_format.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
{{ docStringPackage $.Package }}
1919
func {{ .GenericName "f" }}(t T, {{ params .Params }}, msg string, args ...any) {{ returns .Returns }} {
2020
if h, ok := t.(H); ok { h.Helper() }
21-
return {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args))
21+
return {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)...)
2222
}
2323
{{- end }}
2424

codegen/internal/generator/templates/assertion_forward.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (a *{{ $.Receiver }}) {{.Name}}({{ params .Params }}, msgAndArgs ...any) {{
4343
{{ docStringPackage $.Package }}
4444
func (a *{{ $.Receiver }}){{ .Name }}f({{ params .Params }}, msg string, args ...any) {{ returns .Returns }} {
4545
if h, ok := a.T.(H); ok { h.Helper() }
46-
return {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args))
46+
return {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...)
4747
}
4848
{{- end }}
4949
{{- end }}

codegen/internal/generator/templates/requirement_format.gotmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
func {{ .GenericName "f" }}(t T, {{ params .Params }}, msg string, args ...any) {
2222
if h, ok := t.(H); ok { h.Helper() }
2323
{{- if or (eq .Name "Fail") (eq .Name "FailNow") }}{{/* special semantics for these two, which can only fail */}}
24-
_ = {{ .TargetPackage }}.{{ .Name }}(t, {{ forward .Params }}, forwardArgs(msg, args))
24+
_ = {{ .TargetPackage }}.{{ .Name }}(t, {{ forward .Params }}, forwardArgs(msg, args)...)
2525
{{- else }}
26-
if {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)) {
26+
if {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)...) {
2727
return
2828
}
2929
{{- end }}

codegen/internal/generator/templates/requirement_forward.gotmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ func (a *{{ $.Receiver }}){{ .Name }}f({{ params .Params }}, msg string, args ..
5555
h.Helper()
5656
}
5757
{{- if or (eq .Name "Fail") (eq .Name "FailNow") }}{{/* special sema.Tics for these two, which can only fail */}}
58-
_ = {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args))
58+
_ = {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...)
5959
{{- else }}
60-
if {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)) {
60+
if {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...) {
6161
return
6262
}
6363
{{- end }}

docs/doc-site/api/json.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func main() {
148148
|--|--|
149149
| [`assertions.JSONEq(t T, expected string, actual string, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#JSONEq) | internal implementation |
150150

151-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEq](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L66)
151+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEq](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L65)
152152
{{% /tab %}}
153153
{{< /tabs >}}
154154

@@ -261,7 +261,7 @@ func main() {
261261
|--|--|
262262
| [`assertions.JSONEqBytes(t T, expected []byte, actual []byte, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#JSONEqBytes) | internal implementation |
263263

264-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEqBytes](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L26)
264+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEqBytes](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L25)
265265

266266
> **Maintainer Note**
267267
>
@@ -382,7 +382,7 @@ func main() {
382382
|--|--|
383383
| [`assertions.JSONEqT[EDoc, ADoc RText](t T, expected EDoc, actual ADoc, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#JSONEqT) | internal implementation |
384384

385-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEqT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L91)
385+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONEqT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L90)
386386
{{% /tab %}}
387387
{{< /tabs >}}
388388

@@ -511,7 +511,7 @@ type dummyStruct struct {
511511
|--|--|
512512
| [`assertions.JSONMarshalAsT[EDoc RText](t T, expected EDoc, object any, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#JSONMarshalAsT) | internal implementation |
513513

514-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONMarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L162)
514+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONMarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L161)
515515
{{% /tab %}}
516516
{{< /tabs >}}
517517

@@ -642,7 +642,7 @@ type dummyStruct struct {
642642
|--|--|
643643
| [`assertions.JSONUnmarshalAsT[Object any, ADoc RText](t T, expected Object, jazon ADoc, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#JSONUnmarshalAsT) | internal implementation |
644644

645-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONUnmarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L125)
645+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#JSONUnmarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/json.go#L124)
646646
{{% /tab %}}
647647
{{< /tabs >}}
648648

docs/doc-site/api/yaml.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ See [YAMLEqBytes](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#YAM
7777
|--|--|
7878
| [`assertions.YAMLEq(t T, expected string, actual string, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#YAMLEq) | internal implementation |
7979

80-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEq](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L79)
80+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEq](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L78)
8181
{{% /tab %}}
8282
{{< /tabs >}}
8383

@@ -148,7 +148,7 @@ For dynamic redaction of the input text via a callback, use [YAMLEqT](https://pk
148148
|--|--|
149149
| [`assertions.YAMLEqBytes(t T, expected []byte, actual []byte, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#YAMLEqBytes) | internal implementation |
150150

151-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEqBytes](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L48)
151+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEqBytes](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L47)
152152
{{% /tab %}}
153153
{{< /tabs >}}
154154

@@ -192,7 +192,7 @@ NOTE: passed values (expected, actual) may be wrapped as functions to redact the
192192
|--|--|
193193
| [`assertions.YAMLEqT[EDoc, ADoc RText](t T, expected EDoc, actual ADoc, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#YAMLEqT) | internal implementation |
194194

195-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEqT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L100)
195+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLEqT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L99)
196196
{{% /tab %}}
197197
{{< /tabs >}}
198198

@@ -247,7 +247,7 @@ NOTE: passed expected value may be wrapped as a function to redact the input tex
247247
|--|--|
248248
| [`assertions.YAMLMarshalAsT[EDoc RText](t T, expected EDoc, object any, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#YAMLMarshalAsT) | internal implementation |
249249

250-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLMarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L171)
250+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLMarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L170)
251251
{{% /tab %}}
252252
{{< /tabs >}}
253253

@@ -304,7 +304,7 @@ NOTE: passed yamlDoc value may be wrapped as a function to redact the input text
304304
|--|--|
305305
| [`assertions.YAMLUnmarshalAsT[Object any, ADoc RText](t T, expected Object, yamlDoc ADoc, msgAndArgs ...any) bool`](https://pkg.go.dev/github.com/go-openapi/testify/v2/internal/assertions#YAMLUnmarshalAsT) | internal implementation |
306306

307-
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLUnmarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L134)
307+
**Source:** [github.com/go-openapi/testify/v2/internal/assertions#YAMLUnmarshalAsT](https://github.com/go-openapi/testify/blob/master/internal/assertions/yaml.go#L133)
308308
{{% /tab %}}
309309
{{< /tabs >}}
310310

internal/assertions/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func typeAndKind(v any) (reflect.Type, reflect.Kind) {
6767

6868
k := t.Kind()
6969

70-
if k == reflect.Ptr {
70+
if k == reflect.Pointer {
7171
t = t.Elem()
7272
k = t.Kind()
7373
}

0 commit comments

Comments
 (0)