forked from mirror/client_golang
Adjust TestRegisterWithOrGet to the present
Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
0a8115f42e
commit
e1fb14a776
|
@ -738,14 +738,8 @@ func BenchmarkHandler(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterWithOrGet(t *testing.T) {
|
func TestAlreadyRegistered(t *testing.T) {
|
||||||
// Replace the default registerer just to be sure. This is bad, but this
|
reg := prometheus.NewRegistry()
|
||||||
// whole test will go away once RegisterOrGet is removed.
|
|
||||||
oldRegisterer := prometheus.DefaultRegisterer
|
|
||||||
defer func() {
|
|
||||||
prometheus.DefaultRegisterer = oldRegisterer
|
|
||||||
}()
|
|
||||||
prometheus.DefaultRegisterer = prometheus.NewRegistry()
|
|
||||||
original := prometheus.NewCounterVec(
|
original := prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
|
@ -761,11 +755,11 @@ func TestRegisterWithOrGet(t *testing.T) {
|
||||||
[]string{"foo", "bar"},
|
[]string{"foo", "bar"},
|
||||||
)
|
)
|
||||||
var err error
|
var err error
|
||||||
if err = prometheus.Register(original); err != nil {
|
if err = reg.Register(original); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = prometheus.Register(equalButNotSame); err == nil {
|
if err = reg.Register(equalButNotSame); err == nil {
|
||||||
t.Fatal("expected error when registringe equal collector")
|
t.Fatal("expected error when registering equal collector")
|
||||||
}
|
}
|
||||||
if are, ok := err.(prometheus.AlreadyRegisteredError); ok {
|
if are, ok := err.(prometheus.AlreadyRegisteredError); ok {
|
||||||
if are.ExistingCollector != original {
|
if are.ExistingCollector != original {
|
||||||
|
|
Loading…
Reference in New Issue