MCPcopy Create free account
hub / github.com/prometheus/common / TestToFormatType

Function TestToFormatType

expfmt/expfmt_test.go:25–97  ·  view source on GitHub ↗

Test Format to Escaping Scheme conversion.

(t *testing.T)

Source from the content-addressed store, hash-verified

23
24// Test Format to Escaping Scheme conversion.
25func 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",

Callers

nothing calls this directly

Calls 2

FormatTypeMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…