-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(script): include task null outputs
- Loading branch information
1 parent
aa8588c
commit b133210
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
core/src/test/java/io/kestra/core/runners/NullOutputTest.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,47 @@ | ||
package io.kestra.core.runners; | ||
|
||
import io.kestra.core.junit.annotations.KestraTest; | ||
import io.kestra.core.junit.extensions.LoadFlows; | ||
import io.kestra.core.models.executions.Execution; | ||
import io.kestra.core.models.flows.State; | ||
import io.kestra.core.queues.QueueException; | ||
import io.kestra.core.utils.TestsUtils; | ||
import jakarta.inject.Inject; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
@KestraTest | ||
public class NullOutputTest { | ||
@Inject | ||
protected StandAloneRunner runner; | ||
|
||
@Inject | ||
protected RunnerUtils runnerUtils; | ||
|
||
@BeforeEach | ||
protected void init() throws IOException, URISyntaxException { | ||
if (!runner.isRunning()) { | ||
runner.run(); | ||
} | ||
} | ||
|
||
@Test | ||
@LoadFlows("flows/valids/null-output.yaml") | ||
void shouldIncludeNullOutput() throws QueueException, TimeoutException { | ||
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "null-output"); | ||
|
||
assertThat(execution, notNullValue()); | ||
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); | ||
assertThat(execution.getTaskRunList(), hasSize(1)); | ||
assertThat(execution.getTaskRunList().getFirst().getOutputs(), aMapWithSize(1)); | ||
assertThat(execution.getTaskRunList().getFirst().getOutputs().containsKey("value"), is(true)); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
core/src/test/java/io/kestra/core/tasks/test/NullOutputTask.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,30 @@ | ||
package io.kestra.core.tasks.test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import io.kestra.core.models.annotations.Plugin; | ||
import io.kestra.core.models.tasks.RunnableTask; | ||
import io.kestra.core.models.tasks.Task; | ||
import io.kestra.core.runners.RunContext; | ||
import lombok.*; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@SuperBuilder | ||
@ToString | ||
@EqualsAndHashCode | ||
@Getter | ||
@NoArgsConstructor | ||
@Plugin | ||
public class NullOutputTask extends Task implements RunnableTask<NullOutputTask.Output> { | ||
|
||
@Override | ||
public Output run(RunContext runContext) throws Exception { | ||
return Output.builder().build(); | ||
} | ||
|
||
@Builder | ||
@Getter | ||
public static class Output implements io.kestra.core.models.tasks.Output { | ||
@JsonInclude(JsonInclude.Include.ALWAYS) | ||
private String value; | ||
} | ||
} |
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,6 @@ | ||
id: null-output | ||
namespace: io.kestra.tests | ||
|
||
tasks: | ||
- id: null-output | ||
type: io.kestra.core.tasks.test.NullOutputTask |
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