mirror of https://github.com/stretchr/testify.git
Merge branch 'master' into fix/equal-exported-values-accepts-everything
commit
109f4286cf
|
@ -16,6 +16,6 @@ jobs:
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Create GitHub release from tag
|
- name: Create GitHub release from tag
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|
|
@ -104,8 +104,8 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
|
||||||
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
@ -186,7 +186,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
|
||||||
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
|
@ -186,8 +186,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
|
||||||
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValues(uint32(123), int32(123))
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -197,8 +197,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
|
||||||
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
@ -336,7 +336,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
|
||||||
// a.EventuallyWithT(func(c *assert.CollectT) {
|
// a.EventuallyWithT(func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
@ -361,7 +361,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor
|
||||||
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
|
@ -576,8 +576,8 @@ func truncatingFormat(data interface{}) string {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValues(t, uint32(123), int32(123))
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
@ -1940,7 +1940,7 @@ func (*CollectT) Copy(TestingT) {
|
||||||
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
10
mock/mock.go
10
mock/mock.go
|
@ -766,7 +766,15 @@ const (
|
||||||
// AnythingOfTypeArgument contains the type of an argument
|
// AnythingOfTypeArgument contains the type of an argument
|
||||||
// for use when type checking. Used in [Arguments.Diff] and [Arguments.Assert].
|
// for use when type checking. Used in [Arguments.Diff] and [Arguments.Assert].
|
||||||
//
|
//
|
||||||
// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead.
|
// Deprecated: this is an implementation detail that must not be used. Use the [AnythingOfType] constructor instead, example:
|
||||||
|
//
|
||||||
|
// m.On("Do", mock.AnythingOfType("string"))
|
||||||
|
//
|
||||||
|
// All explicit type declarations can be replaced with interface{} as is expected by [Mock.On], example:
|
||||||
|
//
|
||||||
|
// func anyString interface{} {
|
||||||
|
// return mock.AnythingOfType("string")
|
||||||
|
// }
|
||||||
type AnythingOfTypeArgument = anythingOfTypeArgument
|
type AnythingOfTypeArgument = anythingOfTypeArgument
|
||||||
|
|
||||||
// anythingOfTypeArgument is a string that contains the type of an argument
|
// anythingOfTypeArgument is a string that contains the type of an argument
|
||||||
|
|
|
@ -232,8 +232,8 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValues(t, uint32(123), int32(123))
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -246,8 +246,8 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
@ -418,7 +418,7 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
|
||||||
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
|
func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
@ -446,7 +446,7 @@ func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitF
|
||||||
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
|
func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
|
@ -187,8 +187,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
|
||||||
EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValues(uint32(123), int32(123))
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
@ -198,8 +198,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
|
||||||
EqualValues(a.t, expected, actual, msgAndArgs...)
|
EqualValues(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
@ -337,7 +337,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
|
||||||
// a.EventuallyWithT(func(c *assert.CollectT) {
|
// a.EventuallyWithT(func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
|
func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
@ -362,7 +362,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), w
|
||||||
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
|
func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
Loading…
Reference in New Issue