cloudflare/cloudflared
Publicmirrored from https://github.com/cloudflare/cloudflaredAvailable
metrics/timer_test.go
24lines · modeblame
d06fc520Areg Harutyunyan8 years ago | 1 | package metrics |
| 2 | | |
| 3 | import ( | |
| 4 | "testing" | |
| 5 | "time" | |
| 6 | | |
| 7 | "github.com/prometheus/client_golang/prometheus" | |
| 8 | "github.com/stretchr/testify/assert" | |
| 9 | ) | |
| 10 | | |
| 11 | func TestEnd(t *testing.T) { | |
| 12 | m := prometheus.NewHistogramVec( | |
| 13 | prometheus.HistogramOpts{ | |
| 14 | Namespace: "TestCallLatencyWithoutMeasurement", | |
| 15 | Name: "Latency", | |
| 16 | Buckets: prometheus.LinearBuckets(0, 50, 100), | |
| 17 | }, | |
| 18 | []string{"key"}, | |
| 19 | ) | |
| 20 | timer := NewTimer(m, time.Millisecond, "key") | |
| 21 | assert.Equal(t, time.Duration(0), timer.End("dne")) | |
| 22 | timer.Start("test") | |
| 23 | assert.NotEqual(t, time.Duration(0), timer.End("test")) | |
| 24 | } |