(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestCollectorFuncWithRegistry(t *testing.T) { |
| 57 | reg := NewPedanticRegistry() |
| 58 | |
| 59 | cf := CollectorFunc(func(ch chan<- Metric) { |
| 60 | ch <- MustNewConstMetric( |
| 61 | NewDesc( |
| 62 | "test_metric", |
| 63 | "A test metric", |
| 64 | nil, nil, |
| 65 | ), |
| 66 | GaugeValue, |
| 67 | 42.0, |
| 68 | ) |
| 69 | }) |
| 70 | |
| 71 | if err := reg.Register(cf); err != nil { |
| 72 | t.Errorf("Failed to register CollectorFunc: %v", err) |
| 73 | } |
| 74 | |
| 75 | collectedMetrics, err := reg.Gather() |
| 76 | if err != nil { |
| 77 | t.Errorf("Failed to gather metrics: %v", err) |
| 78 | } |
| 79 | |
| 80 | if len(collectedMetrics) != 1 { |
| 81 | t.Errorf("Expected 1 metric family, got %d", len(collectedMetrics)) |
| 82 | } |
| 83 | } |
nothing calls this directly
no test coverage detected