From 591927d4170508f003a3d1d06fc49a12d4db7a49 Mon Sep 17 00:00:00 2001 From: Bob Callaway Date: Wed, 1 Feb 2023 06:45:42 -0800 Subject: [PATCH] fix: fix regex for multi-digit counts Signed-off-by: Bob Callaway --- cmd/rekor-server/e2e_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/rekor-server/e2e_test.go b/cmd/rekor-server/e2e_test.go index 7fac3aae8..b0002e059 100644 --- a/cmd/rekor-server/e2e_test.go +++ b/cmd/rekor-server/e2e_test.go @@ -108,7 +108,7 @@ func TestMetricsCounts(t *testing.T) { } func getRekorMetricCount(metricLine string, t *testing.T) (int, error) { t.Helper() - re, err := regexp.Compile(fmt.Sprintf("^%s.*([0-9]+)$", regexp.QuoteMeta(metricLine))) + re, err := regexp.Compile(fmt.Sprintf("^%s\\s*([0-9]+)$", regexp.QuoteMeta(metricLine))) if err != nil { return 0, err } @@ -128,7 +128,7 @@ func getRekorMetricCount(metricLine string, t *testing.T) (int, error) { result, err := strconv.Atoi(match[1]) if err != nil { - return 0, nil + return 0, err } t.Log("Matched metric line: " + scanner.Text()) return result, nil