Skip to content

Commit

Permalink
Update testify and fix filebeat tests (elastic#42747)
Browse files Browse the repository at this point in the history
Testify 1.10 fixed NotSame which exposes a bug in our filebeat tests:
stretchr/testify@118fb83

Remove the structure comparison, as they will never be the same address.
Require that the maps they hold have a different backing.
  • Loading branch information
haesbaert authored Feb 19, 2025
1 parent d6ff82b commit 3ff1931
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22940,11 +22940,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------
Dependency : github.com/stretchr/testify
Version: v1.9.0
Version: v1.10.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.9.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.10.0/LICENSE:

MIT License

Expand Down
11 changes: 7 additions & 4 deletions filebeat/channel/runner_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package channel

import (
"reflect"
"testing"

"github.com/elastic/beats/v7/libbeat/beat"
Expand Down Expand Up @@ -69,17 +70,19 @@ func (r runnerFactoryMock) Assert(t *testing.T) {
// we need to make sure `Assert` is called after `Create`
require.Len(t, r.cfgs, r.clientCount)

sameBacking := func(a, b any) bool {
return reflect.ValueOf(a).UnsafePointer() == reflect.ValueOf(b).UnsafePointer()
}

t.Run("new processing configuration each time", func(t *testing.T) {
for i, c1 := range r.cfgs {
for j, c2 := range r.cfgs {
if i == j {
continue
}

require.NotSamef(t, c1.Processing, c2.Processing, "processing configuration cannot be re-used")
require.NotSamef(t, c1.Processing.Meta, c2.Processing.Meta, "`Processing.Meta` cannot be re-used")
require.NotSamef(t, c1.Processing.Fields, c2.Processing.Fields, "`Processing.Fields` cannot be re-used")
require.NotSamef(t, c1.Processing.Processor, c2.Processing.Processor, "`Processing.Processor` cannot be re-used")
require.Falsef(t, sameBacking(c1.Processing.Meta, c2.Processing.Meta), "`Processing.Meta` cannot be re-used")
require.Falsef(t, sameBacking(c1.Processing.Fields, c2.Processing.Fields), "`Processing.Fields` cannot be re-used")
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/ugorji/go/codec v1.1.8
github.com/vmware/govmomi v0.39.0
go.elastic.co/ecszap v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8=
github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
Expand Down

0 comments on commit 3ff1931

Please sign in to comment.