Test Format to Escaping Scheme conversion.
(t *testing.T)
| 23 | |
| 24 | // Test Format to Escaping Scheme conversion. |
| 25 | func TestToFormatType(t *testing.T) { |
| 26 | tests := []struct { |
| 27 | format Format |
| 28 | expected FormatType |
| 29 | }{ |
| 30 | { |
| 31 | format: FmtProtoCompact, |
| 32 | expected: TypeProtoCompact, |
| 33 | }, |
| 34 | { |
| 35 | format: FmtProtoDelim, |
| 36 | expected: TypeProtoDelim, |
| 37 | }, |
| 38 | { |
| 39 | format: FmtProtoText, |
| 40 | expected: TypeProtoText, |
| 41 | }, |
| 42 | { |
| 43 | format: FmtOpenMetrics_1_0_0, |
| 44 | expected: TypeOpenMetrics, |
| 45 | }, |
| 46 | { |
| 47 | format: FmtText, |
| 48 | expected: TypeTextPlain, |
| 49 | }, |
| 50 | { |
| 51 | format: FmtOpenMetrics_0_0_1, |
| 52 | expected: TypeOpenMetrics, |
| 53 | }, |
| 54 | { |
| 55 | format: "application/vnd.google.protobuf; proto=BadProtocol; encoding=text", |
| 56 | expected: TypeUnknown, |
| 57 | }, |
| 58 | { |
| 59 | format: "application/vnd.google.protobuf", |
| 60 | expected: TypeUnknown, |
| 61 | }, |
| 62 | { |
| 63 | format: "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily=bad", |
| 64 | expected: TypeUnknown, |
| 65 | }, |
| 66 | // encoding missing |
| 67 | { |
| 68 | format: "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily", |
| 69 | expected: TypeUnknown, |
| 70 | }, |
| 71 | // invalid encoding |
| 72 | { |
| 73 | format: "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=textual", |
| 74 | expected: TypeUnknown, |
| 75 | }, |
| 76 | // bad charset, must be utf-8 |
| 77 | { |
| 78 | format: "application/openmetrics-text; version=1.0.0; charset=ascii", |
| 79 | expected: TypeUnknown, |
| 80 | }, |
| 81 | { |
| 82 | format: "text/plain", |
nothing calls this directly
no test coverage detected
searching dependent graphs…