mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 23:42:32 +00:00
Add some unit tests for pkg/labels/labels.go (#7358)
This PR is about adding some unit tests for pkg/labels/labels.go. Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
This commit is contained in:
parent
e963d953ea
commit
e5ffa8c9a0
@ -544,3 +544,71 @@ func TestLabels_WithoutLabels(t *testing.T) {
|
||||
func TestLabels_FromStrings(t *testing.T) {
|
||||
testutil.Equals(t, Labels{{"aaa", "111"}, {"bbb", "222"}}, FromStrings("aaa", "111", "bbb", "222"))
|
||||
}
|
||||
|
||||
func TestBulider_NewBulider(t *testing.T) {
|
||||
testutil.Equals(
|
||||
t,
|
||||
&Builder{
|
||||
base: Labels{{"aaa", "111"}},
|
||||
del: []string{},
|
||||
add: []Label{},
|
||||
},
|
||||
NewBuilder(Labels{{"aaa", "111"}}),
|
||||
)
|
||||
}
|
||||
|
||||
func TestBuilder_Del(t *testing.T) {
|
||||
testutil.Equals(
|
||||
t,
|
||||
&Builder{
|
||||
del: []string{"bbb"},
|
||||
add: []Label{{"aaa", "111"}, {"ccc", "333"}},
|
||||
},
|
||||
(&Builder{
|
||||
del: []string{},
|
||||
add: []Label{{"aaa", "111"}, {"bbb", "222"}, {"ccc", "333"}},
|
||||
}).Del("bbb"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestBuilder_Set(t *testing.T) {
|
||||
testutil.Equals(
|
||||
t,
|
||||
&Builder{
|
||||
base: Labels{{"aaa", "111"}},
|
||||
del: []string{},
|
||||
add: []Label{{"bbb", "222"}},
|
||||
},
|
||||
(&Builder{
|
||||
base: Labels{{"aaa", "111"}},
|
||||
del: []string{},
|
||||
add: []Label{},
|
||||
}).Set("bbb", "222"),
|
||||
)
|
||||
|
||||
testutil.Equals(
|
||||
t,
|
||||
&Builder{
|
||||
base: Labels{{"aaa", "111"}},
|
||||
del: []string{},
|
||||
add: []Label{{"bbb", "333"}},
|
||||
},
|
||||
(&Builder{
|
||||
base: Labels{{"aaa", "111"}},
|
||||
del: []string{},
|
||||
add: []Label{{"bbb", "222"}},
|
||||
}).Set("bbb", "333"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestBuilder_Labels(t *testing.T) {
|
||||
testutil.Equals(
|
||||
t,
|
||||
Labels{{"aaa", "111"}, {"ccc", "333"}, {"ddd", "444"}},
|
||||
(&Builder{
|
||||
base: Labels{{"aaa", "111"}, {"bbb", "222"}, {"ccc", "333"}},
|
||||
del: []string{"bbb"},
|
||||
add: []Label{{"ddd", "444"}},
|
||||
}).Labels(),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user