(t testing.TB)
| 43 | } |
| 44 | |
| 45 | func testTextParse(t testing.TB) { |
| 46 | scenarios := []struct { |
| 47 | in string |
| 48 | out []*dto.MetricFamily |
| 49 | }{ |
| 50 | // 0: Empty lines as input. |
| 51 | { |
| 52 | in: ` |
| 53 | |
| 54 | `, |
| 55 | out: []*dto.MetricFamily{}, |
| 56 | }, |
| 57 | // 1: Minimal case. |
| 58 | { |
| 59 | in: ` |
| 60 | minimal_metric 1.234 |
| 61 | another_metric -3e3 103948 |
| 62 | # Even that: |
| 63 | no_labels{} 3 |
| 64 | # HELP line for non-existing metric will be ignored. |
| 65 | `, |
| 66 | out: []*dto.MetricFamily{ |
| 67 | { |
| 68 | Name: proto.String("minimal_metric"), |
| 69 | Type: dto.MetricType_UNTYPED.Enum(), |
| 70 | Metric: []*dto.Metric{ |
| 71 | { |
| 72 | Untyped: &dto.Untyped{ |
| 73 | Value: proto.Float64(1.234), |
| 74 | }, |
| 75 | }, |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | Name: proto.String("another_metric"), |
| 80 | Type: dto.MetricType_UNTYPED.Enum(), |
| 81 | Metric: []*dto.Metric{ |
| 82 | { |
| 83 | Untyped: &dto.Untyped{ |
| 84 | Value: proto.Float64(-3e3), |
| 85 | }, |
| 86 | TimestampMs: proto.Int64(103948), |
| 87 | }, |
| 88 | }, |
| 89 | }, |
| 90 | { |
| 91 | Name: proto.String("no_labels"), |
| 92 | Type: dto.MetricType_UNTYPED.Enum(), |
| 93 | Metric: []*dto.Metric{ |
| 94 | { |
| 95 | Untyped: &dto.Untyped{ |
| 96 | Value: proto.Float64(3), |
| 97 | }, |
| 98 | }, |
| 99 | }, |
| 100 | }, |
| 101 | }, |
| 102 | }, |
no test coverage detected