|
|
@@ -156,8 +156,9 @@ func TestPrefixedRegistryGetOrRegister(t *testing.T) {
|
|
|
|
|
|
func TestPrefixedRegistryRegister(t *testing.T) {
|
|
|
r := NewPrefixedRegistry("prefix.")
|
|
|
-
|
|
|
err := r.Register("foo", NewCounter())
|
|
|
+ c := NewCounter()
|
|
|
+ Register("bar", c)
|
|
|
if err != nil {
|
|
|
t.Fatal(err.Error())
|
|
|
}
|
|
|
@@ -223,3 +224,24 @@ func TestPrefixedChildRegistryGet(t *testing.T) {
|
|
|
t.Fatal(name)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestChildPrefixedRegistryRegister(t *testing.T) {
|
|
|
+ r := NewPrefixedChildRegistry(DefaultRegistry, "prefix.")
|
|
|
+ err := r.Register("foo", NewCounter())
|
|
|
+ c := NewCounter()
|
|
|
+ Register("bar", c)
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err.Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ i := 0
|
|
|
+ r.Each(func(name string, m interface{}) {
|
|
|
+ i++
|
|
|
+ if name != "prefix.foo" {
|
|
|
+ t.Fatal(name)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if i != 1 {
|
|
|
+ t.Fatal(i)
|
|
|
+ }
|
|
|
+}
|