TestRegisterUnregisterCollector ensures registering and unregistering a collector doesn't leave any dangling metrics. We use NewGoCollector as a nice concrete example of a collector with multiple metrics.
(t *testing.T)
| 877 | // We use NewGoCollector as a nice concrete example of a collector with |
| 878 | // multiple metrics. |
| 879 | func TestRegisterUnregisterCollector(t *testing.T) { |
| 880 | col := prometheus.NewGoCollector() |
| 881 | |
| 882 | reg := prometheus.NewRegistry() |
| 883 | reg.MustRegister(col) |
| 884 | reg.Unregister(col) |
| 885 | if metrics, err := reg.Gather(); err != nil { |
| 886 | t.Error("error gathering sample metric") |
| 887 | } else if len(metrics) != 0 { |
| 888 | t.Error("should have unregistered metric") |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | // TestHistogramVecRegisterGatherConcurrency is an end-to-end test that |
| 893 | // concurrently calls Observe on random elements of a HistogramVec while the |
nothing calls this directly
no test coverage detected