@@ -14,32 +14,32 @@ import (
1414
1515func TestGetTasksToEvict_Table (t * testing.T ) {
1616 tests := []struct {
17- name string
18- job * PodGroupInfo
19- tasksToEvict bool
20- expectTasks [] string
17+ name string
18+ job * PodGroupInfo
19+ expectedHasMoreTasks bool
20+ numExpectTasks int
2121 }{
2222 {
2323 name : "WithoutSubGroups_EvictOne" ,
2424 job : & PodGroupInfo {
2525 PodInfos : pod_info.PodsMap {
2626 "pod-a" : simpleTask ("pod-a" , "" , pod_status .Running ),
27- "pod-b" : simpleTask ("pod-a " , "" , pod_status .Running ),
27+ "pod-b" : simpleTask ("pod-b " , "" , pod_status .Running ),
2828 "pod-c" : simpleTask ("pod-c" , "" , pod_status .Running ),
2929 },
3030 MinAvailable : 1 ,
3131 },
32- tasksToEvict : true ,
33- expectTasks : [] string { "pod-a" } ,
32+ expectedHasMoreTasks : true ,
33+ numExpectTasks : 1 ,
3434 },
3535 {
3636 name : "WithoutSubGroups_EmptyQueue" ,
3737 job : & PodGroupInfo {
3838 PodInfos : pod_info.PodsMap {},
3939 MinAvailable : 1 ,
4040 },
41- tasksToEvict : false ,
42- expectTasks : [] string {} ,
41+ expectedHasMoreTasks : false ,
42+ numExpectTasks : 0 ,
4343 },
4444 {
4545 name : "WithoutSubGroups_MultipleEvict" ,
@@ -50,8 +50,8 @@ func TestGetTasksToEvict_Table(t *testing.T) {
5050 },
5151 MinAvailable : 2 ,
5252 },
53- tasksToEvict : false ,
54- expectTasks : [] string { "pod-a" , "pod-b" } ,
53+ expectedHasMoreTasks : false ,
54+ numExpectTasks : 2 ,
5555 },
5656 {
5757 name : "WithSubGroups_SingleEvict" ,
@@ -66,8 +66,8 @@ func TestGetTasksToEvict_Table(t *testing.T) {
6666 pg .AddTaskInfo (simpleTask ("pod-3" , "sg2" , pod_status .Running ))
6767 return pg
6868 }(),
69- tasksToEvict : true ,
70- expectTasks : [] string { "pod-3" } ,
69+ expectedHasMoreTasks : true ,
70+ numExpectTasks : 1 ,
7171 },
7272 {
7373 name : "WithSubGroups_EvictAll" ,
@@ -86,21 +86,16 @@ func TestGetTasksToEvict_Table(t *testing.T) {
8686 MinAvailable : 2 ,
8787 }
8888 }(),
89- tasksToEvict : false ,
90- expectTasks : [] string { "pod-1" , "pod-2" } ,
89+ expectedHasMoreTasks : false ,
90+ numExpectTasks : 2 ,
9191 },
9292 }
9393
9494 for _ , tt := range tests {
9595 t .Run (tt .name , func (t * testing.T ) {
96- var tasks []* pod_info.PodInfo
97- tasks , tasksToEvict := GetTasksToEvict (tt .job , subGroupOrderFn , tasksOrderFn )
98- assert .Equal (t , tt .tasksToEvict , tasksToEvict )
99- var actualTaskNames []string
100- for _ , pod := range tasks {
101- actualTaskNames = append (actualTaskNames , pod .Name )
102- }
103- assert .ElementsMatch (t , tt .expectTasks , actualTaskNames )
96+ tasksToEvict , hasMoreTasks := GetTasksToEvict (tt .job , subGroupOrderFn , tasksOrderFn )
97+ assert .Equal (t , tt .expectedHasMoreTasks , hasMoreTasks )
98+ assert .Equal (t , tt .numExpectTasks , len (tasksToEvict ))
10499 })
105100 }
106101}
0 commit comments