MCPcopy
hub / github.com/google/mtail / TestTimer

Function TestTimer

internal/metrics/metric_test.go:217–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

215}
216
217func TestTimer(t *testing.T) {
218 m := NewMetric("test", "prog", Timer, Int)
219 n := NewMetric("test", "prog", Timer, Int)
220 testutil.ExpectNoDiff(t, m, n, testutil.IgnoreUnexported(sync.RWMutex{}, Metric{}))
221 d, _ := m.GetDatum()
222 datum.IncIntBy(d, 1, time.Now().UTC())
223 lv := m.FindLabelValueOrNil([]string{})
224 if lv == nil {
225 t.Fatal("couldn't find labelvalue")
226 }
227 newD := lv.Value
228 if newD == nil {
229 t.Errorf("new_d is nil")
230 }
231 if newD.ValueString() != "1" {
232 t.Errorf("value not 1")
233 }
234}
235
236func TestRemoveMetricLabelValue(t *testing.T) {
237 m := NewMetric("test", "prog", Counter, Int, "a", "b", "c")

Callers

nothing calls this directly

Calls 7

GetDatumMethod · 0.95
FindLabelValueOrNilMethod · 0.95
ExpectNoDiffFunction · 0.92
IgnoreUnexportedFunction · 0.92
IncIntByFunction · 0.92
NewMetricFunction · 0.85
ValueStringMethod · 0.65

Tested by

no test coverage detected