forked from lsjostro/prometheus-plugin
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
at least test that nothing crashes on null
- Loading branch information
waschndolos
committed
Jan 6, 2024
1 parent
366d672
commit bbcbe6b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/test/java/org/jenkinsci/plugins/prometheus/util/FlowNodesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} |