(t testing.TB)
| 24 | ) |
| 25 | |
| 26 | func testTextParse(t testing.TB) { |
| 27 | scenarios := []struct { |
| 28 | in string |
| 29 | out []*dto.MetricFamily |
| 30 | }{ |
| 31 | // 0: Empty lines as input. |
| 32 | { |
| 33 | in: ` |
| 34 | |
| 35 | `, |
| 36 | out: []*dto.MetricFamily{}, |
| 37 | }, |
| 38 | // 1: Minimal case. |
| 39 | { |
| 40 | in: ` |
| 41 | minimal_metric 1.234 |
| 42 | another_metric -3e3 103948 |
| 43 | # Even that: |
| 44 | no_labels{} 3 |
| 45 | # HELP line for non-existing metric will be ignored. |
| 46 | `, |
| 47 | out: []*dto.MetricFamily{ |
| 48 | { |
| 49 | Name: proto.String("minimal_metric"), |
| 50 | Type: dto.MetricType_UNTYPED.Enum(), |
| 51 | Metric: []*dto.Metric{ |
| 52 | { |
| 53 | Untyped: &dto.Untyped{ |
| 54 | Value: proto.Float64(1.234), |
| 55 | }, |
| 56 | }, |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | Name: proto.String("another_metric"), |
| 61 | Type: dto.MetricType_UNTYPED.Enum(), |
| 62 | Metric: []*dto.Metric{ |
| 63 | { |
| 64 | Untyped: &dto.Untyped{ |
| 65 | Value: proto.Float64(-3e3), |
| 66 | }, |
| 67 | TimestampMs: proto.Int64(103948), |
| 68 | }, |
| 69 | }, |
| 70 | }, |
| 71 | { |
| 72 | Name: proto.String("no_labels"), |
| 73 | Type: dto.MetricType_UNTYPED.Enum(), |
| 74 | Metric: []*dto.Metric{ |
| 75 | { |
| 76 | Untyped: &dto.Untyped{ |
| 77 | Value: proto.Float64(3), |
| 78 | }, |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
no test coverage detected