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

Function TestEqualSamples

model/value_test.go:25–158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestEqualSamples(t *testing.T) {
26 testSample := &Sample{}
27
28 tests := map[string]struct {
29 in1, in2 *Sample
30 want bool
31 }{
32 "equal pointers": {
33 in1: testSample,
34 in2: testSample,
35 want: true,
36 },
37 "different metrics": {
38 in1: &Sample{Metric: Metric{"foo": "bar"}},
39 in2: &Sample{Metric: Metric{"foo": "biz"}},
40 want: false,
41 },
42 "different timestamp": {
43 in1: &Sample{Timestamp: 0},
44 in2: &Sample{Timestamp: 1},
45 want: false,
46 },
47 "different value": {
48 in1: &Sample{Value: 0},
49 in2: &Sample{Value: 1},
50 want: false,
51 },
52 "equal samples": {
53 in1: &Sample{
54 Metric: Metric{"foo": "bar"},
55 Timestamp: 0,
56 Value: 1,
57 },
58 in2: &Sample{
59 Metric: Metric{"foo": "bar"},
60 Timestamp: 0,
61 Value: 1,
62 },
63 want: true,
64 },
65 "equal histograms": {
66 in1: &Sample{
67 Metric: Metric{"foo": "bar"},
68 Timestamp: 0,
69 Histogram: genSampleHistogram(),
70 },
71 in2: &Sample{
72 Metric: Metric{"foo": "bar"},
73 Timestamp: 0,
74 Histogram: genSampleHistogram(),
75 },
76 want: true,
77 },
78 "different histogram counts": {
79 in1: &Sample{
80 Metric: Metric{"foo": "bar"},
81 Timestamp: 0,
82 Histogram: &SampleHistogram{

Callers

nothing calls this directly

Calls 2

genSampleHistogramFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected