mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Add a unit test for MergeLabels in storage/remote/codec.go. (#7499)
This PR is about adding a unit test for MergeLabels in storage/remote/codec.go. Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
This commit is contained in:
parent
98a69b77d1
commit
b962029031
|
@ -210,3 +210,22 @@ func TestNegotiateResponseType(t *testing.T) {
|
|||
testutil.NotOk(t, err, "expected error due to not supported requested response types")
|
||||
testutil.Equals(t, "server does not support any of the requested response types: [20]; supported: map[SAMPLES:{} STREAMED_XOR_CHUNKS:{}]", err.Error())
|
||||
}
|
||||
|
||||
func TestMergeLabels(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
primary, secondary, expected []prompb.Label
|
||||
}{
|
||||
{
|
||||
primary: []prompb.Label{{Name: "aaa", Value: "foo"}, {Name: "bbb", Value: "foo"}, {Name: "ddd", Value: "foo"}},
|
||||
secondary: []prompb.Label{{Name: "bbb", Value: "bar"}, {Name: "ccc", Value: "bar"}},
|
||||
expected: []prompb.Label{{Name: "aaa", Value: "foo"}, {Name: "bbb", Value: "foo"}, {Name: "ccc", Value: "bar"}, {Name: "ddd", Value: "foo"}},
|
||||
},
|
||||
{
|
||||
primary: []prompb.Label{{Name: "bbb", Value: "bar"}, {Name: "ccc", Value: "bar"}},
|
||||
secondary: []prompb.Label{{Name: "aaa", Value: "foo"}, {Name: "bbb", Value: "foo"}, {Name: "ddd", Value: "foo"}},
|
||||
expected: []prompb.Label{{Name: "aaa", Value: "foo"}, {Name: "bbb", Value: "bar"}, {Name: "ccc", Value: "bar"}, {Name: "ddd", Value: "foo"}},
|
||||
},
|
||||
} {
|
||||
testutil.Equals(t, tc.expected, MergeLabels(tc.primary, tc.secondary))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue