From 841b03b0f66638ed9342d1cba58abadf8f217007 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Mon, 13 May 2024 15:44:27 +0300 Subject: [PATCH] test(promhandler): properly compare label matchers --- internal/promhandler/params_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/promhandler/params_test.go b/internal/promhandler/params_test.go index eeb7f049..5c7918ba 100644 --- a/internal/promhandler/params_test.go +++ b/internal/promhandler/params_test.go @@ -103,7 +103,19 @@ func TestParseLabelMatchers(t *testing.T) { return } require.NoError(t, err) - require.Equal(t, tt.want, got) + + // LabelMatcher cannot be compared with DeepEqual. + // + // See https://github.com/prometheus/prometheus/blob/3b8b57700c469c7cde84e1d8f9d383cb8fe11ab0/promql/parser/parse_test.go#L3719. + require.Len(t, got, len(tt.want)) + for i, set := range tt.want { + gotSet := got[i] + require.Len(t, gotSet, len(set)) + for i, m := range set { + gotMatcher := gotSet[i] + require.Equal(t, m.String(), gotMatcher.String()) + } + } }) } }