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

Function TestLabelSetMerge

model/labelset_test.go:84–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestLabelSetMerge(t *testing.T) {
85 labelSet := LabelSet{
86 "monitor": "codelab",
87 "foo": "bar",
88 "bar": "baz",
89 }
90
91 labelSet2 := LabelSet{
92 "monitor": "codelab",
93 "dolor": "mi",
94 "lorem": "ipsum",
95 }
96
97 expectedSet := LabelSet{
98 "monitor": "codelab",
99 "foo": "bar",
100 "bar": "baz",
101 "dolor": "mi",
102 "lorem": "ipsum",
103 }
104
105 mergedSet := labelSet.Merge(labelSet2)
106
107 if len(mergedSet) != len(expectedSet) {
108 t.Errorf("expected the length of the cloned Label set to be %d, but got %d",
109 len(expectedSet), len(mergedSet))
110 }
111
112 for ln, lv := range mergedSet {
113 expected := expectedSet[ln]
114 if expected != lv {
115 t.Errorf("expected to get LabelValue %s, but got %s for LabelName %s", expected, lv, ln)
116 }
117 }
118}

Callers

nothing calls this directly

Calls 1

MergeMethod · 0.95

Tested by

no test coverage detected