Package list golang-github-go-kit-kit / 4e88882
metrics/pcp: fix tests Suyash 5 years ago
1 changed file(s) with 36 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
66 )
77
88 func TestCounter(t *testing.T) {
9 r := NewReporter("test_counter")
10 counter := r.NewCounter("speed_counter").With("label values", "not supported").(*Counter)
9 r, err := NewReporter("test_counter")
10 if err != nil {
11 t.Fatal(err)
12 }
13
14 counter, err := r.NewCounter("speed_counter")
15 if err != nil {
16 t.Fatal(err)
17 }
18
19 counter = counter.With("label values", "not supported").(*Counter)
20
1121 value := func() float64 { f := counter.c.Val(); return float64(f) }
1222 if err := teststat.TestCounter(counter, value); err != nil {
1323 t.Fatal(err)
1525 }
1626
1727 func TestGauge(t *testing.T) {
18 r := NewReporter("test_gauge")
19 gauge := r.NewGauge("speed_gauge").With("label values", "not supported").(*Gauge)
28 r, err := NewReporter("test_gauge")
29 if err != nil {
30 t.Fatal(err)
31 }
32
33 gauge, err := r.NewGauge("speed_gauge")
34 if err != nil {
35 t.Fatal(err)
36 }
37
38 gauge = gauge.With("label values", "not supported").(*Gauge)
39
2040 value := func() float64 { f := gauge.g.Val(); return f }
2141 if err := teststat.TestGauge(gauge, value); err != nil {
2242 t.Fatal(err)
2444 }
2545
2646 func TestHistogram(t *testing.T) {
27 r := NewReporter("test_histogram")
28 histogram := r.NewHistogram("speed_histogram").With("label values", "not supported").(*Histogram)
47 r, err := NewReporter("test_histogram")
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 histogram, err := r.NewHistogram("speed_histogram", 0, 3600000000)
53 if err != nil {
54 t.Fatal(err)
55 }
56
57 histogram = histogram.With("label values", "not supported").(*Histogram)
58
2959 quantiles := func() (float64, float64, float64, float64) {
3060 p50 := float64(histogram.Percentile(50))
3161 p90 := float64(histogram.Percentile(90))