tsdb tests: use go-cmp instead of DeepEquals

Also one simpler call checking nil.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2024-01-25 22:55:58 +00:00
parent 17f48f2b3b
commit 12cac5bd5c
2 changed files with 7 additions and 6 deletions

View file

@ -679,10 +679,10 @@ func TestHead_ReadWAL(t *testing.T) {
s50 := head.series.getByID(50) s50 := head.series.getByID(50)
s100 := head.series.getByID(100) s100 := head.series.getByID(100)
require.Equal(t, labels.FromStrings("a", "1"), s10.lset) testutil.RequireEqual(t, labels.FromStrings("a", "1"), s10.lset)
require.Equal(t, (*memSeries)(nil), s11) // Series without samples should be garbage collected at head.Init(). require.Nil(t, s11) // Series without samples should be garbage collected at head.Init().
require.Equal(t, labels.FromStrings("a", "4"), s50.lset) testutil.RequireEqual(t, labels.FromStrings("a", "4"), s50.lset)
require.Equal(t, labels.FromStrings("a", "3"), s100.lset) testutil.RequireEqual(t, labels.FromStrings("a", "3"), s100.lset)
expandChunk := func(c chunkenc.Iterator) (x []sample) { expandChunk := func(c chunkenc.Iterator) (x []sample) {
for c.Next() == chunkenc.ValFloat { for c.Next() == chunkenc.ValFloat {
@ -709,7 +709,7 @@ func TestHead_ReadWAL(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
e, err := q.Select(0, 1000, []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "1")}) e, err := q.Select(0, 1000, []*labels.Matcher{labels.MustNewMatcher(labels.MatchEqual, "a", "1")})
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, exemplar.Exemplar{Ts: 100, Value: 1, Labels: labels.FromStrings("traceID", "asdf")}, e[0].Exemplars[0]) require.True(t, exemplar.Exemplar{Ts: 100, Value: 1, Labels: labels.FromStrings("traceID", "asdf")}.Equals(e[0].Exemplars[0]))
}) })
} }
} }

View file

@ -25,6 +25,7 @@ import (
"github.com/prometheus/prometheus/tsdb/chunks" "github.com/prometheus/prometheus/tsdb/chunks"
"github.com/prometheus/prometheus/tsdb/fileutil" "github.com/prometheus/prometheus/tsdb/fileutil"
"github.com/prometheus/prometheus/tsdb/index" "github.com/prometheus/prometheus/tsdb/index"
"github.com/prometheus/prometheus/util/testutil"
) )
func TestRepairBadIndexVersion(t *testing.T) { func TestRepairBadIndexVersion(t *testing.T) {
@ -112,7 +113,7 @@ func TestRepairBadIndexVersion(t *testing.T) {
} }
require.NoError(t, p.Err()) require.NoError(t, p.Err())
require.Equal(t, []labels.Labels{ testutil.RequireEqual(t, []labels.Labels{
labels.FromStrings("a", "1", "b", "1"), labels.FromStrings("a", "1", "b", "1"),
labels.FromStrings("a", "2", "b", "1"), labels.FromStrings("a", "2", "b", "1"),
}, res) }, res)