mirror of https://github.com/stretchr/testify.git
Merge branch 'master' into master
commit
8302de98b1
|
@ -1,7 +1,9 @@
|
|||
Testify - Thou Shalt Write Tests
|
||||
================================
|
||||
|
||||
ℹ️ We are working on testify v2 and would love to hear what you'd like to see in it, have your say here: https://cutt.ly/testify
|
||||
> [!NOTE]
|
||||
> Testify is being maintained at v1, no breaking changes will be accepted in this repo.
|
||||
> [See discussion about v2](https://github.com/stretchr/testify/discussions/1560).
|
||||
|
||||
[](https://github.com/stretchr/testify/actions/workflows/main.yml) [](https://goreportcard.com/report/github.com/stretchr/testify) [](https://pkg.go.dev/github.com/stretchr/testify)
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -621,21 +621,6 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ..
|
|||
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
|
||||
}
|
||||
|
||||
if aType.Kind() == reflect.Ptr {
|
||||
aType = aType.Elem()
|
||||
}
|
||||
if bType.Kind() == reflect.Ptr {
|
||||
bType = bType.Elem()
|
||||
}
|
||||
|
||||
if aType.Kind() != reflect.Struct {
|
||||
return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...)
|
||||
}
|
||||
|
||||
if bType.Kind() != reflect.Struct {
|
||||
return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
|
||||
}
|
||||
|
||||
expected = copyExportedFields(expected)
|
||||
actual = copyExportedFields(actual)
|
||||
|
||||
|
|
|
@ -449,6 +449,56 @@ func TestEqualExportedValues(t *testing.T) {
|
|||
+ Exported: (int) 1,
|
||||
notExported: (interface {}) <nil>`,
|
||||
},
|
||||
{
|
||||
value1: []int{1, 2},
|
||||
value2: []int{1, 2},
|
||||
expectedEqual: true,
|
||||
},
|
||||
{
|
||||
value1: []int{1, 2},
|
||||
value2: []int{1, 3},
|
||||
expectedEqual: false,
|
||||
expectedFail: `
|
||||
Diff:
|
||||
--- Expected
|
||||
+++ Actual
|
||||
@@ -2,3 +2,3 @@
|
||||
(int) 1,
|
||||
- (int) 2
|
||||
+ (int) 3
|
||||
}`,
|
||||
},
|
||||
{
|
||||
value1: []*Nested{
|
||||
{1, 2},
|
||||
{3, 4},
|
||||
},
|
||||
value2: []*Nested{
|
||||
{1, "a"},
|
||||
{3, "b"},
|
||||
},
|
||||
expectedEqual: true,
|
||||
},
|
||||
{
|
||||
value1: []*Nested{
|
||||
{1, 2},
|
||||
{3, 4},
|
||||
},
|
||||
value2: []*Nested{
|
||||
{1, "a"},
|
||||
{2, "b"},
|
||||
},
|
||||
expectedEqual: false,
|
||||
expectedFail: `
|
||||
Diff:
|
||||
--- Expected
|
||||
+++ Actual
|
||||
@@ -6,3 +6,3 @@
|
||||
(*assert.Nested)({
|
||||
- Exported: (int) 3,
|
||||
+ Exported: (int) 2,
|
||||
notExported: (interface {}) <nil>`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
|
1
doc.go
1
doc.go
|
@ -1,4 +1,3 @@
|
|||
// ** We are working on testify v2 and would love to hear what you'd like to see in it, have your say here: https://cutt.ly/testify **
|
||||
// Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend.
|
||||
//
|
||||
// testify contains the following packages:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
{{.Comment}}
|
||||
{{ replace .Comment "assert." "require."}}
|
||||
func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
|
||||
if h, ok := t.(tHelper); ok { h.Helper() }
|
||||
if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }
|
||||
|
|
Loading…
Reference in New Issue