mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
rebase: bump github.com/stretchr/testify from 1.8.2 to 1.8.3
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.3. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.3) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
268ac42850
commit
1ab92441dd
2
go.mod
2
go.mod
@ -26,7 +26,7 @@ require (
|
|||||||
github.com/onsi/gomega v1.27.6
|
github.com/onsi/gomega v1.27.6
|
||||||
github.com/pkg/xattr v0.4.9
|
github.com/pkg/xattr v0.4.9
|
||||||
github.com/prometheus/client_golang v1.15.1
|
github.com/prometheus/client_golang v1.15.1
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.3
|
||||||
golang.org/x/crypto v0.9.0
|
golang.org/x/crypto v0.9.0
|
||||||
golang.org/x/net v0.10.0
|
golang.org/x/net v0.10.0
|
||||||
golang.org/x/sys v0.8.0
|
golang.org/x/sys v0.8.0
|
||||||
|
5
go.sum
5
go.sum
@ -1074,7 +1074,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
@ -1084,8 +1083,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI=
|
github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI=
|
||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
42
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
42
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
@ -90,6 +90,23 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args
|
|||||||
return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
|
return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualExportedValuesf asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
|
||||||
|
// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
|
||||||
|
func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
@ -155,6 +172,31 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
|
|||||||
return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
|
return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventuallyWithTf asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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 {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
// Exactlyf asserts that two objects are equal in value and type.
|
// Exactlyf asserts that two objects are equal in value and type.
|
||||||
//
|
//
|
||||||
// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
|
// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted")
|
||||||
|
84
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
84
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
@ -155,6 +155,40 @@ func (a *Assertions) EqualErrorf(theError error, errString string, msg string, a
|
|||||||
return EqualErrorf(a.t, theError, errString, msg, args...)
|
return EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualExportedValues asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// a.EqualExportedValues(S{1, 2}, S{1, 3}) => true
|
||||||
|
// a.EqualExportedValues(S{1, 2}, S{2, 3}) => false
|
||||||
|
func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EqualExportedValues(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualExportedValuesf asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
|
||||||
|
// a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
|
||||||
|
func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
@ -288,6 +322,56 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
|
|||||||
return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
|
return Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// a.EventuallyWithT(func(c *assert.CollectT) {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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 {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventuallyWithTf asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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 {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Eventuallyf asserts that given condition will be met in waitFor time,
|
// Eventuallyf asserts that given condition will be met in waitFor time,
|
||||||
// periodically checking target function each tick.
|
// periodically checking target function each tick.
|
||||||
//
|
//
|
||||||
|
202
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
202
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
@ -75,6 +75,77 @@ func ObjectsAreEqual(expected, actual interface{}) bool {
|
|||||||
return bytes.Equal(exp, act)
|
return bytes.Equal(exp, act)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copyExportedFields iterates downward through nested data structures and creates a copy
|
||||||
|
// that only contains the exported struct fields.
|
||||||
|
func copyExportedFields(expected interface{}) interface{} {
|
||||||
|
if isNil(expected) {
|
||||||
|
return expected
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedType := reflect.TypeOf(expected)
|
||||||
|
expectedKind := expectedType.Kind()
|
||||||
|
expectedValue := reflect.ValueOf(expected)
|
||||||
|
|
||||||
|
switch expectedKind {
|
||||||
|
case reflect.Struct:
|
||||||
|
result := reflect.New(expectedType).Elem()
|
||||||
|
for i := 0; i < expectedType.NumField(); i++ {
|
||||||
|
field := expectedType.Field(i)
|
||||||
|
isExported := field.IsExported()
|
||||||
|
if isExported {
|
||||||
|
fieldValue := expectedValue.Field(i)
|
||||||
|
if isNil(fieldValue) || isNil(fieldValue.Interface()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
newValue := copyExportedFields(fieldValue.Interface())
|
||||||
|
result.Field(i).Set(reflect.ValueOf(newValue))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.Interface()
|
||||||
|
|
||||||
|
case reflect.Ptr:
|
||||||
|
result := reflect.New(expectedType.Elem())
|
||||||
|
unexportedRemoved := copyExportedFields(expectedValue.Elem().Interface())
|
||||||
|
result.Elem().Set(reflect.ValueOf(unexportedRemoved))
|
||||||
|
return result.Interface()
|
||||||
|
|
||||||
|
case reflect.Array, reflect.Slice:
|
||||||
|
result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len())
|
||||||
|
for i := 0; i < expectedValue.Len(); i++ {
|
||||||
|
index := expectedValue.Index(i)
|
||||||
|
if isNil(index) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
unexportedRemoved := copyExportedFields(index.Interface())
|
||||||
|
result.Index(i).Set(reflect.ValueOf(unexportedRemoved))
|
||||||
|
}
|
||||||
|
return result.Interface()
|
||||||
|
|
||||||
|
case reflect.Map:
|
||||||
|
result := reflect.MakeMap(expectedType)
|
||||||
|
for _, k := range expectedValue.MapKeys() {
|
||||||
|
index := expectedValue.MapIndex(k)
|
||||||
|
unexportedRemoved := copyExportedFields(index.Interface())
|
||||||
|
result.SetMapIndex(k, reflect.ValueOf(unexportedRemoved))
|
||||||
|
}
|
||||||
|
return result.Interface()
|
||||||
|
|
||||||
|
default:
|
||||||
|
return expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObjectsExportedFieldsAreEqual determines if the exported (public) fields of two objects are
|
||||||
|
// considered equal. This comparison of only exported fields is applied recursively to nested data
|
||||||
|
// structures.
|
||||||
|
//
|
||||||
|
// This function does no assertion of any kind.
|
||||||
|
func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool {
|
||||||
|
expectedCleaned := copyExportedFields(expected)
|
||||||
|
actualCleaned := copyExportedFields(actual)
|
||||||
|
return ObjectsAreEqualValues(expectedCleaned, actualCleaned)
|
||||||
|
}
|
||||||
|
|
||||||
// ObjectsAreEqualValues gets whether two objects are equal, or if their
|
// ObjectsAreEqualValues gets whether two objects are equal, or if their
|
||||||
// values are equal.
|
// values are equal.
|
||||||
func ObjectsAreEqualValues(expected, actual interface{}) bool {
|
func ObjectsAreEqualValues(expected, actual interface{}) bool {
|
||||||
@ -473,6 +544,50 @@ func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interfa
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualExportedValues asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
|
||||||
|
// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
|
||||||
|
func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
|
||||||
|
aType := reflect.TypeOf(expected)
|
||||||
|
bType := reflect.TypeOf(actual)
|
||||||
|
|
||||||
|
if aType != bType {
|
||||||
|
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if aType.Kind() != reflect.Struct {
|
||||||
|
return Fail(t, fmt.Sprintf("Types expected to both be 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 \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected = copyExportedFields(expected)
|
||||||
|
actual = copyExportedFields(actual)
|
||||||
|
|
||||||
|
if !ObjectsAreEqualValues(expected, actual) {
|
||||||
|
diff := diff(expected, actual)
|
||||||
|
expected, actual = formatUnequalValues(expected, actual)
|
||||||
|
return Fail(t, fmt.Sprintf("Not equal (comparing only exported fields): \n"+
|
||||||
|
"expected: %s\n"+
|
||||||
|
"actual : %s%s", expected, actual, diff), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Exactly asserts that two objects are equal in value and type.
|
// Exactly asserts that two objects are equal in value and type.
|
||||||
//
|
//
|
||||||
// assert.Exactly(t, int32(123), int64(123))
|
// assert.Exactly(t, int32(123), int64(123))
|
||||||
@ -794,10 +909,10 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{})
|
|||||||
|
|
||||||
ok, found := containsElement(s, contains)
|
ok, found := containsElement(s, contains)
|
||||||
if !ok {
|
if !ok {
|
||||||
return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...)
|
||||||
}
|
}
|
||||||
if found {
|
if found {
|
||||||
return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("%#v should not contain %#v", s, contains), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -1744,6 +1859,89 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CollectT implements the TestingT interface and collects all errors.
|
||||||
|
type CollectT struct {
|
||||||
|
errors []error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf collects the error.
|
||||||
|
func (c *CollectT) Errorf(format string, args ...interface{}) {
|
||||||
|
c.errors = append(c.errors, fmt.Errorf(format, args...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNow panics.
|
||||||
|
func (c *CollectT) FailNow() {
|
||||||
|
panic("Assertion failed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset clears the collected errors.
|
||||||
|
func (c *CollectT) Reset() {
|
||||||
|
c.errors = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy copies the collected errors to the supplied t.
|
||||||
|
func (c *CollectT) Copy(t TestingT) {
|
||||||
|
if tt, ok := t.(tHelper); ok {
|
||||||
|
tt.Helper()
|
||||||
|
}
|
||||||
|
for _, err := range c.errors {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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 {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
|
||||||
|
collect := new(CollectT)
|
||||||
|
ch := make(chan bool, 1)
|
||||||
|
|
||||||
|
timer := time.NewTimer(waitFor)
|
||||||
|
defer timer.Stop()
|
||||||
|
|
||||||
|
ticker := time.NewTicker(tick)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for tick := ticker.C; ; {
|
||||||
|
select {
|
||||||
|
case <-timer.C:
|
||||||
|
collect.Copy(t)
|
||||||
|
return Fail(t, "Condition never satisfied", msgAndArgs...)
|
||||||
|
case <-tick:
|
||||||
|
tick = nil
|
||||||
|
collect.Reset()
|
||||||
|
go func() {
|
||||||
|
condition(collect)
|
||||||
|
ch <- len(collect.errors) == 0
|
||||||
|
}()
|
||||||
|
case v := <-ch:
|
||||||
|
if v {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
tick = ticker.C
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Never asserts that the given condition doesn't satisfy in waitFor time,
|
// Never asserts that the given condition doesn't satisfy in waitFor time,
|
||||||
// periodically checking the target function each tick.
|
// periodically checking the target function each tick.
|
||||||
//
|
//
|
||||||
|
5
vendor/github.com/stretchr/testify/assert/doc.go
generated
vendored
5
vendor/github.com/stretchr/testify/assert/doc.go
generated
vendored
@ -1,8 +1,9 @@
|
|||||||
// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
|
// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
|
||||||
//
|
//
|
||||||
// Example Usage
|
// # Example Usage
|
||||||
//
|
//
|
||||||
// The following is a complete example using assert in a standard test function:
|
// The following is a complete example using assert in a standard test function:
|
||||||
|
//
|
||||||
// import (
|
// import (
|
||||||
// "testing"
|
// "testing"
|
||||||
// "github.com/stretchr/testify/assert"
|
// "github.com/stretchr/testify/assert"
|
||||||
@ -33,7 +34,7 @@
|
|||||||
// assert.Equal(a, b, "The two words should be the same.")
|
// assert.Equal(a, b, "The two words should be the same.")
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Assertions
|
// # Assertions
|
||||||
//
|
//
|
||||||
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
|
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
|
||||||
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
|
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
|
||||||
|
5
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
5
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
@ -1,9 +1,10 @@
|
|||||||
// Package require implements the same assertions as the `assert` package but
|
// Package require implements the same assertions as the `assert` package but
|
||||||
// stops test execution when a test fails.
|
// stops test execution when a test fails.
|
||||||
//
|
//
|
||||||
// Example Usage
|
// # Example Usage
|
||||||
//
|
//
|
||||||
// The following is a complete example using require in a standard test function:
|
// The following is a complete example using require in a standard test function:
|
||||||
|
//
|
||||||
// import (
|
// import (
|
||||||
// "testing"
|
// "testing"
|
||||||
// "github.com/stretchr/testify/require"
|
// "github.com/stretchr/testify/require"
|
||||||
@ -18,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Assertions
|
// # Assertions
|
||||||
//
|
//
|
||||||
// The `require` package have same global functions as in the `assert` package,
|
// The `require` package have same global functions as in the `assert` package,
|
||||||
// but instead of returning a boolean result they call `t.FailNow()`.
|
// but instead of returning a boolean result they call `t.FailNow()`.
|
||||||
|
96
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
96
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
@ -195,6 +195,46 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualExportedValues asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true
|
||||||
|
// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false
|
||||||
|
func EqualExportedValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if assert.EqualExportedValues(t, expected, actual, msgAndArgs...) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualExportedValuesf asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
|
||||||
|
// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
|
||||||
|
func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if assert.EqualExportedValuesf(t, expected, actual, msg, args...) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
@ -364,6 +404,62 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
|
|||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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{}) {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if assert.EventuallyWithT(t, condition, waitFor, tick, msgAndArgs...) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventuallyWithTf asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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{}) {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if assert.EventuallyWithTf(t, condition, waitFor, tick, msg, args...) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// Eventuallyf asserts that given condition will be met in waitFor time,
|
// Eventuallyf asserts that given condition will be met in waitFor time,
|
||||||
// periodically checking target function each tick.
|
// periodically checking target function each tick.
|
||||||
//
|
//
|
||||||
|
84
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
84
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
@ -156,6 +156,40 @@ func (a *Assertions) EqualErrorf(theError error, errString string, msg string, a
|
|||||||
EqualErrorf(a.t, theError, errString, msg, args...)
|
EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EqualExportedValues asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// a.EqualExportedValues(S{1, 2}, S{1, 3}) => true
|
||||||
|
// a.EqualExportedValues(S{1, 2}, S{2, 3}) => false
|
||||||
|
func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
EqualExportedValues(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualExportedValuesf asserts that the types of two objects are equal and their public
|
||||||
|
// fields are also equal. This is useful for comparing structs that have private fields
|
||||||
|
// that could potentially differ.
|
||||||
|
//
|
||||||
|
// type S struct {
|
||||||
|
// Exported int
|
||||||
|
// notExported int
|
||||||
|
// }
|
||||||
|
// a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true
|
||||||
|
// a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false
|
||||||
|
func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertable to the same types
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
// and equal.
|
// and equal.
|
||||||
//
|
//
|
||||||
@ -289,6 +323,56 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
|
|||||||
Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
|
Eventually(a.t, condition, waitFor, tick, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// a.EventuallyWithT(func(c *assert.CollectT) {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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{}) {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EventuallyWithTf asserts that given condition will be met in waitFor time,
|
||||||
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
// function can use the CollectT to call other assertions.
|
||||||
|
// The condition is considered "met" if no errors are raised in a tick.
|
||||||
|
// The supplied CollectT collects all errors from one tick (if there are any).
|
||||||
|
// If the condition is not met before waitFor, the collected errors of
|
||||||
|
// the last tick are copied to t.
|
||||||
|
//
|
||||||
|
// externalValue := false
|
||||||
|
// go func() {
|
||||||
|
// time.Sleep(8*time.Second)
|
||||||
|
// externalValue = true
|
||||||
|
// }()
|
||||||
|
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
|
// }, 1*time.Second, 10*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{}) {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// Eventuallyf asserts that given condition will be met in waitFor time,
|
// Eventuallyf asserts that given condition will be met in waitFor time,
|
||||||
// periodically checking target function each tick.
|
// periodically checking target function each tick.
|
||||||
//
|
//
|
||||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -479,8 +479,8 @@ github.com/spf13/cobra
|
|||||||
# github.com/spf13/pflag v1.0.5
|
# github.com/spf13/pflag v1.0.5
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/spf13/pflag
|
github.com/spf13/pflag
|
||||||
# github.com/stretchr/testify v1.8.2
|
# github.com/stretchr/testify v1.8.3
|
||||||
## explicit; go 1.13
|
## explicit; go 1.20
|
||||||
github.com/stretchr/testify/assert
|
github.com/stretchr/testify/assert
|
||||||
github.com/stretchr/testify/require
|
github.com/stretchr/testify/require
|
||||||
# go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0
|
# go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0
|
||||||
|
Loading…
Reference in New Issue
Block a user