Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
filter NOT_EXECUTED when findLastExecutionsByScenarioId (#1251)
Browse files Browse the repository at this point in the history
  • Loading branch information
DelaunayAlex committed Feb 7, 2024
1 parent b114d91 commit 4fd5f8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface DatabaseExecutionJpaRepository extends JpaRepository<ScenarioEx

List<ScenarioExecutionEntity> findByScenarioIdOrderByIdDesc(String scenarioId);

@Query("select max(se.id), se.scenarioId from SCENARIO_EXECUTIONS se where se.scenarioId in :scenarioIds group by se.scenarioId")
@Query("select max(se.id), se.scenarioId from SCENARIO_EXECUTIONS se where se.scenarioId in :scenarioIds AND se.status != 'NOT_EXECUTED' group by se.scenarioId")
List<Tuple> findLastExecutionsByScenarioId(@Param("scenarioIds") List<String> scenarioIds);

List<ScenarioExecutionEntity> findAllByScenarioId(String scenarioId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.chutneytesting.execution.infra.storage;

import static com.chutneytesting.server.core.domain.execution.report.ServerReportStatus.FAILURE;
import static com.chutneytesting.server.core.domain.execution.report.ServerReportStatus.NOT_EXECUTED;
import static com.chutneytesting.server.core.domain.execution.report.ServerReportStatus.PAUSED;
import static com.chutneytesting.server.core.domain.execution.report.ServerReportStatus.RUNNING;
import static com.chutneytesting.server.core.domain.execution.report.ServerReportStatus.STOPPED;
Expand Down Expand Up @@ -179,6 +180,18 @@ public void last_execution_return_newest_first() {
assertThat(lastExecutions.get(scenarioIdTwo).info()).hasValue("exec4");
}

@Test
public void last_execution_does_not_return_not_executed() {
String scenarioIdOne = givenScenarioId();
sut.store(scenarioIdOne, buildDetachedExecution(SUCCESS, "exec1", ""));
sut.store(scenarioIdOne, buildDetachedExecution(NOT_EXECUTED, "exec2", ""));

Map<String, ExecutionSummary> lastExecutions = sut.getLastExecutions(List.of(scenarioIdOne, scenarioIdOne));
assertThat(lastExecutions).containsOnlyKeys(scenarioIdOne);
assertThat(lastExecutions.get(scenarioIdOne).info()).hasValue("exec1");
assertThat(lastExecutions.get(scenarioIdOne).status()).isEqualTo(SUCCESS);
}

@Test
public void storage_keeps_all_items() {
String scenarioId = givenScenarioId();
Expand Down

0 comments on commit 4fd5f8b

Please sign in to comment.