Skip to content

Commit

Permalink
at least test that nothing crashes on null
Browse files Browse the repository at this point in the history
  • Loading branch information
waschndolos committed Jan 6, 2024
1 parent 366d672 commit bbcbe6b
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jenkinsci.plugins.prometheus.util;

import com.cloudbees.workflow.rest.external.StageNodeExt;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class FlowNodesTest {

@Mock
private WorkflowRun run;

@Test
void returnEmptyListOnPassingNull() {
when(run.getExecution()).thenReturn(null);
List<StageNodeExt> result = FlowNodes.getSortedStageNodes(run);
assertEquals(0, result.size());
}

}

0 comments on commit bbcbe6b

Please sign in to comment.