From 15f419cc649ff35bea1a12094a9ee792004c3567 Mon Sep 17 00:00:00 2001 From: SP12893678 <36910625+SP12893678@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:51:03 +0800 Subject: [PATCH] [YUNIKORN-2786] Improve convert2Namespace funtion's test coverage --- pkg/admission/util_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/admission/util_test.go b/pkg/admission/util_test.go index d34a952af..7b85d6ba1 100644 --- a/pkg/admission/util_test.go +++ b/pkg/admission/util_test.go @@ -19,6 +19,7 @@ package admission import ( + "reflect" "strings" "testing" @@ -189,3 +190,18 @@ func TestDefaultQueueName(t *testing.T) { t.Fatal("UpdatePodLabelForAdmissionController is not as expected") } } + +func TestConvert2Namespace(t *testing.T) { + configMap := &v1.Namespace{} + result := convert2Namespace(configMap) + assert.Equal(t, result != nil, true) + assert.Equal(t, reflect.DeepEqual(result, configMap), true) + + obj := struct{}{} + result = convert2Namespace(obj) + assert.Equal(t, result == nil, true) + + pod := &v1.Pod{} + result = convert2Namespace(pod) + assert.Equal(t, result == nil, true) +}