|
41 | 41 | @ExtendWith(MockitoExtension.class) |
42 | 42 | @MockitoSettings(strictness = Strictness.LENIENT) |
43 | 43 | class EC2FleetAutoResubmitComputerLauncherTest { |
| 44 | + @Test |
| 45 | + void taskCompleted_should_resubmit_task_with_current_workflowrun_executable() { |
| 46 | + // Setup: the current executable is a WorkflowRun, and the task is a WorkflowJob |
| 47 | + when(executor1.getCurrentExecutable()).thenReturn(workflowRun); |
| 48 | + when(workflowRun.getParent()).thenReturn(workflowJob); |
| 49 | + when(workflowJob.getOwnerTask()).thenReturn(workflowJob); |
| 50 | + when(workflowRun.getActions(any())).thenReturn(Collections.singletonList(action1)); |
| 51 | + when(computer.getExecutors()).thenReturn(Arrays.asList(executor1)); |
| 52 | + |
| 53 | + new EC2FleetAutoResubmitComputerLauncher(baseComputerLauncher) |
| 54 | + .afterDisconnect(computer, taskListener); |
| 55 | + |
| 56 | + verify(queue).schedule2(eq(workflowJob), anyInt(), eq(Arrays.asList(action1))); |
| 57 | + verify(workflowRun, times(1)).getActions(any()); |
| 58 | + } |
44 | 59 |
|
45 | 60 | private MockedStatic<Jenkins> mockedJenkins; |
46 | 61 |
|
@@ -202,8 +217,8 @@ void taskCompleted_should_resubmit_task_with_actions() { |
202 | 217 |
|
203 | 218 | @Test |
204 | 219 | void taskCompleted_should_resubmit_task_with_build_actions() { |
205 | | - when(subTask1.getOwnerTask()).thenReturn(workflowJob); |
206 | | - when(workflowJob.getLastUnsuccessfulBuild()).thenReturn(workflowRun); |
| 220 | + when(subTask1.getOwnerTask()).thenReturn(workflowJob); |
| 221 | + when(workflowJob.getLastBuild()).thenReturn(workflowRun); |
207 | 222 | when(workflowRun.getActions(any())).thenReturn((Collections.singletonList(action1))); |
208 | 223 | when(computer.getExecutors()).thenReturn(Arrays.asList(executor1)); |
209 | 224 | new EC2FleetAutoResubmitComputerLauncher(baseComputerLauncher) |
|
0 commit comments