From 7645b00c11d6fecacab50f478b7607affc9290dc Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Thu, 10 Oct 2019 10:20:19 +0800 Subject: [PATCH] Introduce CollectAndCompare to testutils --- .../src/k8s.io/component-base/metrics/testutil/testutil.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/staging/src/k8s.io/component-base/metrics/testutil/testutil.go b/staging/src/k8s.io/component-base/metrics/testutil/testutil.go index 69e2e630fa2..99e35eb800e 100644 --- a/staging/src/k8s.io/component-base/metrics/testutil/testutil.go +++ b/staging/src/k8s.io/component-base/metrics/testutil/testutil.go @@ -24,6 +24,13 @@ import ( "k8s.io/component-base/metrics" ) +// CollectAndCompare registers the provided Collector with a newly created +// pedantic Registry. It then does the same as GatherAndCompare, gathering the +// metrics from the pedantic Registry. +func CollectAndCompare(c metrics.Collector, expected io.Reader, metricNames ...string) error { + return testutil.CollectAndCompare(c, expected, metricNames...) +} + // GatherAndCompare gathers all metrics from the provided Gatherer and compares // it to an expected output read from the provided Reader in the Prometheus text // exposition format. If any metricNames are provided, only metrics with those