From 4809476c193805156b17dfd5d9a06344fd8eb0fb Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 1 Aug 2018 11:20:03 +0200 Subject: [PATCH] Move prometheusState.reset() to test file. --- metrics/prometheus.go | 10 ---------- metrics/prometheus_test.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/metrics/prometheus.go b/metrics/prometheus.go index 5fce28890..62ad86dea 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -197,16 +197,6 @@ type prometheusState struct { state map[string]*collector } -// reset is a utility method for unit testing. It should be called after each -// test run that changes promState internally in order to avoid dependencies -// between unit tests. -func (ps *prometheusState) reset() { - ps.collectors = make(chan *collector) - ps.describers = []func(ch chan<- *stdprometheus.Desc){} - ps.dynamicConfig = newDynamicConfig() - ps.state = make(map[string]*collector) -} - func (ps *prometheusState) SetDynamicConfig(dynamicConfig *dynamicConfig) { ps.mtx.Lock() defer ps.mtx.Unlock() diff --git a/metrics/prometheus_test.go b/metrics/prometheus_test.go index 41d7ab308..af5a6b52f 100644 --- a/metrics/prometheus_test.go +++ b/metrics/prometheus_test.go @@ -13,6 +13,16 @@ import ( dto "github.com/prometheus/client_model/go" ) +// reset is a utility method for unit testing. It should be called after each +// test run that changes promState internally in order to avoid dependencies +// between unit tests. +func (ps *prometheusState) reset() { + ps.collectors = make(chan *collector) + ps.describers = []func(ch chan<- *prometheus.Desc){} + ps.dynamicConfig = newDynamicConfig() + ps.state = make(map[string]*collector) +} + func TestPrometheus(t *testing.T) { // Reset state of global promState. defer promState.reset()