mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
add unit test TestLabels_String for pkg/labels/labels.go (#7150)
Signed-off-by: ZouYu <zouy.fnst@cn.fujitsu.com>
This commit is contained in:
parent
4b5e7d4984
commit
06493b7034
|
@ -19,6 +19,39 @@ import (
|
|||
"github.com/prometheus/prometheus/util/testutil"
|
||||
)
|
||||
|
||||
func TestLabels_String(t *testing.T) {
|
||||
cases := []struct {
|
||||
lables Labels
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
lables: Labels{
|
||||
{
|
||||
Name: "t1",
|
||||
Value: "t1",
|
||||
},
|
||||
{
|
||||
Name: "t2",
|
||||
Value: "t2",
|
||||
},
|
||||
},
|
||||
expected: "{t1=\"t1\", t2=\"t2\"}",
|
||||
},
|
||||
{
|
||||
lables: Labels{},
|
||||
expected: "{}",
|
||||
},
|
||||
{
|
||||
lables: nil,
|
||||
expected: "{}",
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
str := c.lables.String()
|
||||
testutil.Equals(t, c.expected, str)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLabels_MatchLabels(t *testing.T) {
|
||||
labels := Labels{
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue