From c5f40745908c2f6492ad3ef1024471a23c7bdb01 Mon Sep 17 00:00:00 2001 From: SP12893678 <36910625+SP12893678@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:42:51 +0800 Subject: [PATCH] [YUNIKORN-2786] Improve convert2Namespace funtion's test coverage (#887) ==> body-pr-887-temp <== [YUNIKORN-2786] Improve convert2Namespace funtion's test coverage code review Closes: #887 Signed-off-by: Kuan-Po Tseng --- 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..bcfe41b2c 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) { + namespace := &v1.Namespace{} + result := convert2Namespace(namespace) + assert.Check(t, result != nil) + assert.Check(t, reflect.DeepEqual(result, namespace)) + + obj := struct{}{} + result = convert2Namespace(obj) + assert.Check(t, result == nil) + + pod := &v1.Pod{} + result = convert2Namespace(pod) + assert.Check(t, result == nil) +}