Skip to content

Commit

Permalink
chore(core): add unit test for if nested in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Dec 7, 2024
1 parent a27bb1a commit c6a7c12
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/test/java/io/kestra/plugin/core/flow/IfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.kestra.core.models.flows.State;
import io.kestra.core.queues.QueueException;
import io.kestra.core.runners.AbstractMemoryRunnerTest;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import java.time.Duration;
Expand All @@ -14,6 +15,15 @@
import static org.hamcrest.Matchers.*;

class IfTest extends AbstractMemoryRunnerTest {
@Test
void multipleIf() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if", null,
(f, e) -> Map.of("if1", true, "if2", false, "if3", true));

assertThat(execution.getTaskRunList(), hasSize(12));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}

@Test
void ifTruthy() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "if-condition", null,
Expand Down
57 changes: 57 additions & 0 deletions core/src/test/resources/flows/valids/if.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
id: if
namespace: io.kestra.tests

inputs:
- id: if1
type: BOOLEAN

- id: if2
type: BOOLEAN

- id: if3
type: BOOLEAN

tasks:
- id: parallel
type: io.kestra.plugin.core.flow.Parallel
concurrent: 4
tasks:
- id: if-1
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.if1 }}"
then:
- id: if-1-log
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: if-2
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.if2 }}"
then:
- id: if-2-log
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: if-3
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.if3 }}"
then:
- id: if-3-log
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-1
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-2
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-3
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-4
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-5
type: io.kestra.plugin.core.log.Log
message: "Hello World!"
- id: log-parallel-6
type: io.kestra.plugin.core.log.Log
message: "Hello World!"

0 comments on commit c6a7c12

Please sign in to comment.