From 3f80fe06efe172934acbef04707b58b3bae7b5f2 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Thu, 16 Nov 2017 23:04:33 +0000 Subject: [PATCH] Add simple unit test. Signed-off-by: Lantao Liu --- pkg/server/helpers_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/server/helpers_test.go b/pkg/server/helpers_test.go index 424bc64f8..6a00181b5 100644 --- a/pkg/server/helpers_test.go +++ b/pkg/server/helpers_test.go @@ -126,3 +126,19 @@ func TestGetCgroupsPath(t *testing.T) { assert.Equal(t, test.expected, got) } } + +func TestBuildLabels(t *testing.T) { + configLabels := map[string]string{ + "a": "b", + "c": "d", + } + newLabels := buildLabels(configLabels, containerKindSandbox) + assert.Len(t, newLabels, 3) + assert.Equal(t, "b", newLabels["a"]) + assert.Equal(t, "d", newLabels["c"]) + assert.Equal(t, containerKindSandbox, newLabels[containerKindLabel]) + + newLabels["a"] = "e" + assert.Empty(t, configLabels[containerKindLabel], "should not add new labels into original label") + assert.Equal(t, "b", configLabels["a"], "change in new labels should not affect original label") +}