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

Function TestSampleStreamJSONV2

model/value127_test.go:23–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestSampleStreamJSONV2(t *testing.T) {
24 cases := []struct {
25 name string
26 object SampleStream
27 }{
28 {name: "empty", object: SampleStream{}},
29 {name: "metric only", object: SampleStream{Metric: Metric{}}},
30 {name: "metric ordering", object: SampleStream{Metric: Metric{"a": "", "b": "", "c": "", "d": "", "e": "", "f": "", "g": ""}}},
31 {name: "zero length values", object: SampleStream{Values: []SamplePair{}}},
32 {name: "empty value", object: SampleStream{Values: []SamplePair{{}}}},
33 {name: "populated value", object: SampleStream{Values: []SamplePair{{Timestamp: Time(1), Value: SampleValue(1)}}}},
34 {name: "histogram only", object: SampleStream{Histograms: []SampleHistogramPair{{Timestamp: Time(1), Histogram: &SampleHistogram{}}}}},
35 {name: "metric and values", object: SampleStream{Metric: Metric{}, Values: []SamplePair{}}},
36 {name: "all fields", object: SampleStream{Metric: Metric{}, Values: []SamplePair{{}}, Histograms: []SampleHistogramPair{{Timestamp: Time(1), Histogram: &SampleHistogram{}}}}},
37 }
38
39 for i, v := range cases {
40 testV1V2Marshal(t, fmt.Sprintf("%d_%s", i, v.name), v.object)
41 testRoundTrip(t, fmt.Sprintf("%d_%s", i, v.name), v.object)
42 }
43}

Callers

nothing calls this directly

Calls 4

TimeTypeAlias · 0.85
SampleValueTypeAlias · 0.85
testV1V2MarshalFunction · 0.85
testRoundTripFunction · 0.85

Tested by

no test coverage detected