Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ linters:
- funlen
- godox
- gomoddirectives
- gomodguard
- gomodguard_v2
- exhaustruct
- nlreturn
- nonamedreturns
Expand Down Expand Up @@ -46,6 +48,7 @@ linters:
- legacy
- std-error-handling
paths:
- .worktrees
- third_party$
- builtin$
- examples$
Expand All @@ -61,6 +64,7 @@ formatters:
exclusions:
generated: lax
paths:
- .worktrees
- third_party$
- builtin$
- examples$
Expand Down
274 changes: 137 additions & 137 deletions assert/assert_format.go

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions assert/assert_forward.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
{{ docStringPackage $.Package }}
func {{ .GenericName "f" }}(t T, {{ params .Params }}, msg string, args ...any) {{ returns .Returns }} {
if h, ok := t.(H); ok { h.Helper() }
return {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args))
return {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)...)
}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (a *{{ $.Receiver }}) {{.Name}}({{ params .Params }}, msgAndArgs ...any) {{
{{ docStringPackage $.Package }}
func (a *{{ $.Receiver }}){{ .Name }}f({{ params .Params }}, msg string, args ...any) {{ returns .Returns }} {
if h, ok := a.T.(H); ok { h.Helper() }
return {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args))
return {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...)
}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
func {{ .GenericName "f" }}(t T, {{ params .Params }}, msg string, args ...any) {
if h, ok := t.(H); ok { h.Helper() }
{{- if or (eq .Name "Fail") (eq .Name "FailNow") }}{{/* special semantics for these two, which can only fail */}}
_ = {{ .TargetPackage }}.{{ .Name }}(t, {{ forward .Params }}, forwardArgs(msg, args))
_ = {{ .TargetPackage }}.{{ .Name }}(t, {{ forward .Params }}, forwardArgs(msg, args)...)
{{- else }}
if {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)) {
if {{ .TargetPackage }}.{{ .GenericCallName }}(t, {{ forward .Params }}, forwardArgs(msg, args)...) {
return
}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func (a *{{ $.Receiver }}){{ .Name }}f({{ params .Params }}, msg string, args ..
h.Helper()
}
{{- if or (eq .Name "Fail") (eq .Name "FailNow") }}{{/* special sema.Tics for these two, which can only fail */}}
_ = {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args))
_ = {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...)
{{- else }}
if {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)) {
if {{ .TargetPackage }}.{{ .Name }}(a.T, {{ forward .Params }}, forwardArgs(msg, args)...) {
return
}
{{- end }}
Expand Down
10 changes: 5 additions & 5 deletions docs/doc-site/api/json.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func main() {
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -261,7 +261,7 @@ func main() {
|--|--|
| [`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 |

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

> **Maintainer Note**
>
Expand Down Expand Up @@ -382,7 +382,7 @@ func main() {
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -511,7 +511,7 @@ type dummyStruct struct {
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -642,7 +642,7 @@ type dummyStruct struct {
|--|--|
| [`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 |

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

Expand Down
10 changes: 5 additions & 5 deletions docs/doc-site/api/yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ See [YAMLEqBytes](https://pkg.go.dev/github.com/go-openapi/testify/v2/assert#YAM
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -148,7 +148,7 @@ For dynamic redaction of the input text via a callback, use [YAMLEqT](https://pk
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -192,7 +192,7 @@ NOTE: passed values (expected, actual) may be wrapped as functions to redact the
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -247,7 +247,7 @@ NOTE: passed expected value may be wrapped as a function to redact the input tex
|--|--|
| [`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 |

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

Expand Down Expand Up @@ -304,7 +304,7 @@ NOTE: passed yamlDoc value may be wrapped as a function to redact the input text
|--|--|
| [`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 |

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

Expand Down
2 changes: 1 addition & 1 deletion internal/assertions/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func typeAndKind(v any) (reflect.Type, reflect.Kind) {

k := t.Kind()

if k == reflect.Ptr {
if k == reflect.Pointer {
t = t.Elem()
k = t.Kind()
}
Expand Down
4 changes: 2 additions & 2 deletions internal/assertions/equal_unary.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func isNil(object any) bool {
case
reflect.Chan, reflect.Func,
reflect.Interface, reflect.Map,
reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
reflect.Pointer, reflect.Slice, reflect.UnsafePointer:

return value.IsNil()
default:
Expand Down Expand Up @@ -151,7 +151,7 @@ func isEmptyValue(objValue reflect.Value) bool {
case reflect.Chan, reflect.Map, reflect.Slice:
return objValue.Len() == 0
// non-nil pointers are empty if the value they point to is empty
case reflect.Ptr:
case reflect.Pointer:
return isEmptyValue(objValue.Elem())
default:
return false
Expand Down
6 changes: 3 additions & 3 deletions internal/assertions/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func kindCases() iter.Seq[kindCase] {
{reflect.Float64, 0.0345, true, "is float64"},
{reflect.Map, make(map[string]int), true, "is map"},
{reflect.Bool, true, true, "is bool"},
{reflect.Ptr, new(int), true, "is pointer"},
{reflect.Pointer, new(int), true, "is pointer"},
// False cases
{reflect.String, 13, false, "not string"},
{reflect.Int, [6]int{2, 3, 5, 7, 11, 13}, false, "not int"},
Expand All @@ -297,13 +297,13 @@ func kindCases() iter.Seq[kindCase] {
// Edge cases
// True
{reflect.Invalid, any(nil), true, "legitimate expectation of reflect.Invalid (any)"},
{reflect.Ptr, (*any)(nil), true, "legitimate expectation of reflect.Pointer (*any)"},
{reflect.Pointer, (*any)(nil), true, "legitimate expectation of reflect.Pointer (*any)"},
{reflect.Invalid, (error)(nil), true, "legitimate expectation of reflect.Invalid (error)"},
{reflect.Invalid, nil, true, "legitimate nil input"},
// False
{reflect.Interface, iface, false, "interface returns concrete type (any)"},
{reflect.Interface, errors.New("stuff"), false, "interface returns concrete type (error)"},
{reflect.Invalid, "string", false, "wrong expectation of reflect.Invalid"},
{reflect.Ptr, nil, false, "nil input"},
{reflect.Pointer, nil, false, "nil input"},
})
}
Loading
Loading