Skip to content

Commit

Permalink
Add unit test case for func FromStrings in labels.go (prometheus#7321)
Browse files Browse the repository at this point in the history
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  • Loading branch information
Guangwen Feng authored Jun 24, 2020
1 parent f97d2dd commit b41adab
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/labels/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,27 @@ func TestLabels_Equal(t *testing.T) {
}
}

func TestLabels_FromStrings(t *testing.T) {
labels := FromStrings("aaa", "111", "bbb", "222")
expected := Labels{
{
Name: "aaa",
Value: "111",
},
{
Name: "bbb",
Value: "222",
},
}

testutil.Equals(t, expected, labels, "unexpected labelset")

defer func() { recover() }()
FromStrings("aaa", "111", "bbb")

testutil.Assert(t, false, "did not panic as expected")
}

func TestLabels_Compare(t *testing.T) {
labels := Labels{
{
Expand Down

0 comments on commit b41adab

Please sign in to comment.