From b41adab735d530fc7a20c3acd4bc7ce7a3251388 Mon Sep 17 00:00:00 2001 From: Guangwen Feng Date: Wed, 24 Jun 2020 18:54:30 +0800 Subject: [PATCH] Add unit test case for func FromStrings in labels.go (#7321) Signed-off-by: Guangwen Feng --- pkg/labels/labels_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/labels/labels_test.go b/pkg/labels/labels_test.go index 00d3f6a0a..3e442dffd 100644 --- a/pkg/labels/labels_test.go +++ b/pkg/labels/labels_test.go @@ -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{ {