From b722056698d9487d71d53ef5e3874b0cc87fa707 Mon Sep 17 00:00:00 2001 From: zhoumingcheng Date: Tue, 21 Jun 2022 17:03:43 +0800 Subject: [PATCH] add unit test Signed-off-by: zhoumingcheng --- pkg/kubelet/util/util_unix_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/kubelet/util/util_unix_test.go b/pkg/kubelet/util/util_unix_test.go index f8e208b7867..69c147558ce 100644 --- a/pkg/kubelet/util/util_unix_test.go +++ b/pkg/kubelet/util/util_unix_test.go @@ -180,3 +180,28 @@ func TestGetAddressAndDialer(t *testing.T) { assert.Equal(t, test.expectedAddr, addr) } } + +func TestLocalEndpoint(t *testing.T) { + tests := []struct { + path string + file string + expectError bool + expectedFullPath string + }{ + { + path: "path", + file: "file", + expectError: false, + expectedFullPath: "unix:/path/file.sock", + }, + } + for _, test := range tests { + fullPath, err := LocalEndpoint(test.path, test.file) + if test.expectError { + assert.NotNil(t, err, "expected error") + continue + } + assert.Nil(t, err, "expected no error") + assert.Equal(t, test.expectedFullPath, fullPath) + } +}