Search in sources :

Example 1 with TestType

use of pipelite.tester.TestType in project pipelite by enasequence.

the class TestTypeTest method next.

@Test
public void next() {
    TestType testType = TestType.nonPermanentErrorAndThenSuccess;
    String pipelineName = PipeliteIdCreator.pipelineName();
    String processId = PipeliteIdCreator.processId();
    String stageName = PipeliteIdCreator.stageName();
    testType.register(pipelineName, processId, stageName);
    assertThatThrownBy(() -> testType.lastExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThatThrownBy(() -> testType.lastCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThatThrownBy(() -> testType.lastImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
    assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
    assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
    assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
    assertThat(testType.permanentErrors()).containsExactly(EXIT_CODE_PERMANENT_ERROR);
    SimpleLsfExecutor executor = new SimpleLsfExecutor();
    Stage stage = new Stage(stageName, executor);
    TestType.setLastExitCode(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR), pipelineName, processId, stageName);
    TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
    assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
    assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
    assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
    assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
    assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
    assertThat(executor.getCmd()).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    TestType.setLastExitCode(String.valueOf(EXIT_CODE_SUCCESS), pipelineName, processId, stageName);
    TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
    assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
    assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
    assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
    assertThatThrownBy(() -> testType.nextExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
    assertThatThrownBy(() -> testType.nextCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
    assertThatThrownBy(() -> testType.nextImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
}
Also used : Stage(pipelite.stage.Stage) TestType(pipelite.tester.TestType) SimpleLsfExecutor(pipelite.executor.SimpleLsfExecutor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 SimpleLsfExecutor (pipelite.executor.SimpleLsfExecutor)1 Stage (pipelite.stage.Stage)1 TestType (pipelite.tester.TestType)1