(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestSummaryWithoutObjectives(t *testing.T) { |
| 55 | reg := NewRegistry() |
| 56 | summaryWithEmptyObjectives := NewSummary(SummaryOpts{ |
| 57 | Name: "empty_objectives", |
| 58 | Help: "Test help.", |
| 59 | Objectives: map[float64]float64{}, |
| 60 | }) |
| 61 | if err := reg.Register(summaryWithEmptyObjectives); err != nil { |
| 62 | t.Error(err) |
| 63 | } |
| 64 | summaryWithEmptyObjectives.Observe(3) |
| 65 | summaryWithEmptyObjectives.Observe(0.14) |
| 66 | |
| 67 | m := &dto.Metric{} |
| 68 | if err := summaryWithEmptyObjectives.Write(m); err != nil { |
| 69 | t.Error(err) |
| 70 | } |
| 71 | if got, want := m.GetSummary().GetSampleSum(), 3.14; got != want { |
| 72 | t.Errorf("got sample sum %f, want %f", got, want) |
| 73 | } |
| 74 | if got, want := m.GetSummary().GetSampleCount(), uint64(2); got != want { |
| 75 | t.Errorf("got sample sum %d, want %d", got, want) |
| 76 | } |
| 77 | if len(m.GetSummary().Quantile) != 0 { |
| 78 | t.Error("expected no objectives in summary") |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestSummaryWithQuantileLabel(t *testing.T) { |
| 83 | defer func() { |
nothing calls this directly
no test coverage detected