Skip to content

Commit

Permalink
fix(deps): update module github.com/stretchr/testify to v1.10.0 (main) (
Browse files Browse the repository at this point in the history
#10011)

* fix(deps): update module github.com/stretchr/testify to v1.10.0

---------

Signed-off-by: Arve Knudsen <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Arve Knudsen <[email protected]>
Co-authored-by: Charles Korn <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent c178c83 commit d3bd6b4
Show file tree
Hide file tree
Showing 21 changed files with 752 additions and 336 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/segmentio/fasthash v1.0.3
github.com/sirupsen/logrus v1.9.3
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/uber/jaeger-client-go v2.30.0+incompatible
go.uber.org/atomic v1.11.0
go.uber.org/goleak v1.3.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
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.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
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/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4O8IB2ozzxM=
github.com/tencentyun/cos-go-sdk-v5 v0.7.40/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw=
Expand Down
6 changes: 5 additions & 1 deletion pkg/frontend/querymiddleware/querysharding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ func compareExpectedAndActual(t *testing.T, expectedTs, actualTs int64, expected
}
// InEpsilon means the relative error (see https://en.wikipedia.org/wiki/Relative_error#Example) must be less than epsilon (here 1e-12).
// The relative error is calculated using: abs(actual-expected) / abs(expected)
require.InEpsilonf(t, expectedVal, actualVal, tolerance, "%s value at position %d with timestamp %d for series %s", sampleType, j, expectedTs, labels)
if math.IsInf(expectedVal, +1) || math.IsInf(expectedVal, -1) {
require.Equal(t, expectedVal, actualVal)
} else {
require.InEpsilonf(t, expectedVal, actualVal, tolerance, "%s value at position %d with timestamp %d for series %s", sampleType, j, expectedTs, labels)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/frontend/querymiddleware/remote_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/url"
"strconv"
"testing"
"unsafe"

"github.com/gogo/protobuf/proto"
"github.com/golang/snappy"
Expand Down Expand Up @@ -383,7 +384,7 @@ func TestRemoteReadQueryRequest_WithStartEnd(t *testing.T) {
actualReq, ok := actual.(*remoteReadQueryRequest)
require.True(t, ok)
require.NotSame(t, actualReq.query, testData.input.query)
require.NotSame(t, actualReq.query.Matchers, testData.input.query.Matchers)
require.NotSame(t, unsafe.SliceData(actualReq.query.Matchers), unsafe.SliceData(testData.input.query.Matchers))

if actualReq.query.Hints != nil {
require.NotSame(t, actualReq.query.Hints, testData.input.query.Hints)
Expand Down
2 changes: 1 addition & 1 deletion pkg/mimirpb/timeseries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPreallocTimeseriesSliceFromPool(t *testing.T) {
first := PreallocTimeseriesSliceFromPool()
second := PreallocTimeseriesSliceFromPool()

assert.NotSame(t, first, second)
assert.NotSame(t, unsafe.SliceData(first), unsafe.SliceData(second))
})

t.Run("instance is cleaned before reusing", func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ func TestInstantVectorSelector_SliceSizing(t *testing.T) {
}

func requireNotSameSlices[T any](t *testing.T, s1, s2 []T, description string, context string) {
require.NotSamef(t, s1, s2, "%v: must not point to the same %v slice", context, description)

// require.NotSame only checks the slice headers are different. It does not check that the slices do not point the same underlying arrays.
// So specifically check if the first elements are different.
// Check that the two slices do not share the same backing array.
// Note that this condition is sufficient for the cases we want to catch above, but this condition is not generally
// sufficient for checking if two slices share the same underlying array.
if len(s1) > 0 && len(s2) > 0 {
require.NotSamef(t, &s1[0], &s2[0], "%v: must not point to the same underlying %v array", context, description)
}
Expand Down
19 changes: 10 additions & 9 deletions pkg/streamingpromql/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package testutils

import (
"math"
"testing"

"github.com/prometheus/prometheus/model/histogram"
Expand Down Expand Up @@ -45,7 +46,7 @@ func RequireEqualResults(t testing.TB, expr string, expected, actual *promql.Res
require.Equal(t, expectedSample.Metric, actualSample.Metric)
require.Equal(t, expectedSample.T, actualSample.T)
require.Equal(t, expectedSample.H, actualSample.H)
requireInEpsilonIfNotZero(t, expectedSample.F, actualSample.F)
requireInEpsilonIfNotZeroOrInf(t, expectedSample.F, actualSample.F)
}
case parser.ValueTypeMatrix:
expectedMatrix, err := expected.Matrix()
Expand All @@ -64,7 +65,7 @@ func RequireEqualResults(t testing.TB, expr string, expected, actual *promql.Res
actualPoint := actualSeries.Floats[j]

require.Equal(t, expectedPoint.T, actualPoint.T)
requireInEpsilonIfNotZero(t, expectedPoint.F, actualPoint.F, "expected series %v to have points %v, but result is %v", expectedSeries.Metric.String(), expectedSeries.Floats, actualSeries.Floats)
requireInEpsilonIfNotZeroOrInf(t, expectedPoint.F, actualPoint.F, "expected series %v to have points %v, but result is %v", expectedSeries.Metric.String(), expectedSeries.Floats, actualSeries.Floats)
}

for j, expectedPoint := range actualSeries.Histograms {
Expand All @@ -78,15 +79,15 @@ func RequireEqualResults(t testing.TB, expr string, expected, actual *promql.Res
h2 := actualPoint.H

require.Equal(t, h1.Schema, h2.Schema, "histogram schemas match")
requireInEpsilonIfNotZero(t, h1.Count, h2.Count, "histogram counts match")
requireInEpsilonIfNotZero(t, h1.Sum, h2.Sum, "histogram sums match")
requireInEpsilonIfNotZeroOrInf(t, h1.Count, h2.Count, "histogram counts match")
requireInEpsilonIfNotZeroOrInf(t, h1.Sum, h2.Sum, "histogram sums match")

if h1.UsesCustomBuckets() {
requireFloatBucketsMatch(t, h1.CustomValues, h2.CustomValues)
}

requireInEpsilonIfNotZero(t, h1.ZeroThreshold, h2.ZeroThreshold, "histogram thresholds match")
requireInEpsilonIfNotZero(t, h1.ZeroCount, h2.ZeroCount, "histogram zero counts match")
requireInEpsilonIfNotZeroOrInf(t, h1.ZeroThreshold, h2.ZeroThreshold, "histogram thresholds match")
requireInEpsilonIfNotZeroOrInf(t, h1.ZeroCount, h2.ZeroCount, "histogram zero counts match")

requireSpansMatch(t, h1.NegativeSpans, h2.NegativeSpans)
requireFloatBucketsMatch(t, h1.NegativeBuckets, h2.NegativeBuckets)
Expand All @@ -103,8 +104,8 @@ func RequireEqualResults(t testing.TB, expr string, expected, actual *promql.Res
}
}

func requireInEpsilonIfNotZero(t testing.TB, expected, actual float64, msgAndArgs ...interface{}) {
if expected == 0 {
func requireInEpsilonIfNotZeroOrInf(t testing.TB, expected, actual float64, msgAndArgs ...interface{}) {
if expected == 0 || math.IsInf(expected, +1) || math.IsInf(expected, -1) {
require.Equal(t, expected, actual, msgAndArgs...)
} else {
require.InEpsilon(t, expected, actual, 1e-10, msgAndArgs...)
Expand All @@ -114,7 +115,7 @@ func requireInEpsilonIfNotZero(t testing.TB, expected, actual float64, msgAndArg
func requireFloatBucketsMatch(t testing.TB, b1, b2 []float64) {
require.Equal(t, len(b1), len(b2), "bucket lengths match")
for i, b := range b1 {
if b == 0 {
if b == 0 || math.IsInf(b, +1) || math.IsInf(b, -1) {
require.Equal(t, b, b2[i], "bucket values match")
} else {
require.InEpsilon(t, b, b2[i], 1e-10, "bucket values match")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d3bd6b4

Please sign in to comment.