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

filter NOT_EXECUTED when findLastExecutionsByScenarioId #1251

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading