Move prometheusState.reset() to test file.
This commit is contained in:
parent
d727761e5d
commit
4809476c19
2 changed files with 10 additions and 10 deletions
|
@ -197,16 +197,6 @@ type prometheusState struct {
|
||||||
state map[string]*collector
|
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) {
|
func (ps *prometheusState) SetDynamicConfig(dynamicConfig *dynamicConfig) {
|
||||||
ps.mtx.Lock()
|
ps.mtx.Lock()
|
||||||
defer ps.mtx.Unlock()
|
defer ps.mtx.Unlock()
|
||||||
|
|
|
@ -13,6 +13,16 @@ import (
|
||||||
dto "github.com/prometheus/client_model/go"
|
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) {
|
func TestPrometheus(t *testing.T) {
|
||||||
// Reset state of global promState.
|
// Reset state of global promState.
|
||||||
defer promState.reset()
|
defer promState.reset()
|
||||||
|
|
Loading…
Reference in a new issue