From 5706b54b049c3da10551a44e36658c62e8b6a184 Mon Sep 17 00:00:00 2001 From: SP12893678 <36910625+SP12893678@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:38:43 +0200 Subject: [PATCH] [YUNIKORN-2673] Improve newFilter funtion's test coverage (#893) Closes: #893 Signed-off-by: Peter Bacsko --- pkg/scheduler/placement/filter_test.go | 11 +++++++++++ pkg/scheduler/ugm/manager_test.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/placement/filter_test.go b/pkg/scheduler/placement/filter_test.go index 99afc9bb1..0e5d77f48 100644 --- a/pkg/scheduler/placement/filter_test.go +++ b/pkg/scheduler/placement/filter_test.go @@ -144,6 +144,17 @@ func TestNewFilterExpressions(t *testing.T) { if filter.empty { t.Error("filter create did not set empty flag correctly") } + + // test invalid regexp format + conf.Users = []string{"user[a-z"} + conf.Groups = []string{"group[a-z"} + filter = newFilter(conf) + if filter.userExp != nil { + t.Error("The userExp should be nil for an invalid regexp format.") + } + if filter.groupExp != nil { + t.Error("The groupExp should be nil for an invalid regexp format.") + } } // New filter creation failure tests diff --git a/pkg/scheduler/ugm/manager_test.go b/pkg/scheduler/ugm/manager_test.go index 9c571be96..040602a7e 100644 --- a/pkg/scheduler/ugm/manager_test.go +++ b/pkg/scheduler/ugm/manager_test.go @@ -238,7 +238,7 @@ func TestAddRemoveUserAndGroups(t *testing.T) { manager.DecreaseTrackedResource(queuePath1, TestApp1, usage3, user, true) assert.Equal(t, 1, len(manager.GetUsersResources()), "userTrackers count should be 1") - assert.Equal(t, 0, len(manager.GetGroupsResources()), "groupTrackers count should be 1") + assert.Equal(t, 0, len(manager.GetGroupsResources()), "groupTrackers count should be 0") manager.DecreaseTrackedResource(queuePath2, TestApp2, usage2, user1, true) assert.Equal(t, 0, len(manager.GetUsersResources()), "userTrackers count should be 0")