From da217cbde262c056e5582a56d0ef7d353f7a163b Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Tue, 12 May 2020 17:42:21 +0800 Subject: [PATCH] Add some unit tests for funcs in pkg/labels/labels.go (#7116) This PR is about adding some unit tests for funcs in pkg/labels/labels.go. Signed-off-by: Hu Shuai --- pkg/labels/labels_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/labels/labels_test.go b/pkg/labels/labels_test.go index 576a26752..7bffff8af 100644 --- a/pkg/labels/labels_test.go +++ b/pkg/labels/labels_test.go @@ -518,3 +518,16 @@ func TestLabels_Has(t *testing.T) { testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i) } } + +func TestLabels_Get(t *testing.T) { + testutil.Equals(t, "", Labels{{"aaa", "111"}, {"bbb", "222"}}.Get("foo")) + testutil.Equals(t, "111", Labels{{"aaa", "111"}, {"bbb", "222"}}.Get("aaa")) +} + +func TestLabels_Copy(t *testing.T) { + testutil.Equals(t, Labels{{"aaa", "111"}, {"bbb", "222"}}, Labels{{"aaa", "111"}, {"bbb", "222"}}.Copy()) +} + +func TestLabels_Map(t *testing.T) { + testutil.Equals(t, map[string]string{"aaa": "111", "bbb": "222"}, Labels{{"aaa", "111"}, {"bbb", "222"}}.Map()) +}