From d140d148e2ae714b4112bdd9e8843c979debbbcb Mon Sep 17 00:00:00 2001 From: Tim Ramlot <42113979+inteon@users.noreply.github.com> Date: Fri, 23 Aug 2024 11:39:19 +0200 Subject: [PATCH] In https://github.com/prometheus/client_golang/pull/1424, a new check was introduced to make sure the metric with the provided metricName is found. We were depending on it not erroring. This PR removes that assumption and instead makes sure the metric does no longer existi using the CollectAndCount function. Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com> --- pkg/metrics/certificates_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/metrics/certificates_test.go b/pkg/metrics/certificates_test.go index 060d08b7c75..60af9282d7f 100644 --- a/pkg/metrics/certificates_test.go +++ b/pkg/metrics/certificates_test.go @@ -363,16 +363,10 @@ func TestCertificateCache(t *testing.T) { Namespace: "default-unit-test-ns", Name: "crt3", }) - if err := testutil.CollectAndCompare(m.certificateReadyStatus, - strings.NewReader(readyMetadata), - "certmanager_certificate_ready_status", - ); err != nil { - t.Errorf("unexpected collecting result:\n%s", err) + if testutil.CollectAndCount(m.certificateReadyStatus, "certmanager_certificate_ready_status") != 0 { + t.Errorf("unexpected collecting result") } - if err := testutil.CollectAndCompare(m.certificateExpiryTimeSeconds, - strings.NewReader(expiryMetadata), - "certmanager_certificate_expiration_timestamp_seconds", - ); err != nil { - t.Errorf("unexpected collecting result:\n%s", err) + if testutil.CollectAndCount(m.certificateExpiryTimeSeconds, "certmanager_certificate_expiration_timestamp_seconds") != 0 { + t.Errorf("unexpected collecting result") } }