|
|
|
@ -794,6 +794,34 @@ func TestProcessExternalLabels(t *testing.T) {
|
|
|
|
|
externalLabels: labels.Labels{{Name: "a", Value: "c"}},
|
|
|
|
|
expected: labels.Labels{{Name: "a", Value: "b"}},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Test empty externalLabels.
|
|
|
|
|
{
|
|
|
|
|
labels: labels.Labels{{Name: "a", Value: "b"}},
|
|
|
|
|
externalLabels: labels.Labels{},
|
|
|
|
|
expected: labels.Labels{{Name: "a", Value: "b"}},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Test empty labels.
|
|
|
|
|
{
|
|
|
|
|
labels: labels.Labels{},
|
|
|
|
|
externalLabels: labels.Labels{{Name: "a", Value: "b"}},
|
|
|
|
|
expected: labels.Labels{{Name: "a", Value: "b"}},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Test labels is longer than externalLabels.
|
|
|
|
|
{
|
|
|
|
|
labels: labels.Labels{{Name: "a", Value: "b"}, {Name: "c", Value: "d"}},
|
|
|
|
|
externalLabels: labels.Labels{{Name: "e", Value: "f"}},
|
|
|
|
|
expected: labels.Labels{{Name: "a", Value: "b"}, {Name: "c", Value: "d"}, {Name: "e", Value: "f"}},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// Test externalLabels is longer than labels.
|
|
|
|
|
{
|
|
|
|
|
labels: labels.Labels{{Name: "c", Value: "d"}},
|
|
|
|
|
externalLabels: labels.Labels{{Name: "a", Value: "b"}, {Name: "e", Value: "f"}},
|
|
|
|
|
expected: labels.Labels{{Name: "a", Value: "b"}, {Name: "c", Value: "d"}, {Name: "e", Value: "f"}},
|
|
|
|
|
},
|
|
|
|
|
} {
|
|
|
|
|
require.Equal(t, tc.expected, processExternalLabels(tc.labels, tc.externalLabels))
|
|
|
|
|
}
|
|
|
|
|