Skip to content

Commit

Permalink
Adjust TestRegisterWithOrGet to the present (prometheus#477)
Browse files Browse the repository at this point in the history
Signed-off-by: beorn7 <[email protected]>
  • Loading branch information
beorn7 authored and stuartnelson3 committed Oct 10, 2018
1 parent 93edea3 commit e5d4a24
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions prometheus/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,8 @@ func BenchmarkHandler(b *testing.B) {
}
}

func TestRegisterWithOrGet(t *testing.T) {
// Replace the default registerer just to be sure. This is bad, but this
// whole test will go away once RegisterOrGet is removed.
oldRegisterer := prometheus.DefaultRegisterer
defer func() {
prometheus.DefaultRegisterer = oldRegisterer
}()
prometheus.DefaultRegisterer = prometheus.NewRegistry()
func TestAlreadyRegistered(t *testing.T) {
reg := prometheus.NewRegistry()
original := prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "test",
Expand All @@ -761,11 +755,11 @@ func TestRegisterWithOrGet(t *testing.T) {
[]string{"foo", "bar"},
)
var err error
if err = prometheus.Register(original); err != nil {
if err = reg.Register(original); err != nil {
t.Fatal(err)
}
if err = prometheus.Register(equalButNotSame); err == nil {
t.Fatal("expected error when registringe equal collector")
if err = reg.Register(equalButNotSame); err == nil {
t.Fatal("expected error when registering equal collector")
}
if are, ok := err.(prometheus.AlreadyRegisteredError); ok {
if are.ExistingCollector != original {
Expand Down

0 comments on commit e5d4a24

Please sign in to comment.