refactor(tests): move test coverage to InputsTest instead of SubflowRunnerTest

- It is related to serializing inputs at resolving phase only
 - Added Inputs as Java Objects using yml should be serialized/deserialized properly to give the same structure at allValidInputs() test
This commit is contained in:
mustafatarek
2025-12-06 22:40:08 +02:00
committed by Loïc Mathieu
parent a74ebd5cd6
commit 55d0880ed3
5 changed files with 49 additions and 58 deletions

View File

@@ -81,11 +81,28 @@ public class InputsTest {
.put("validatedTime", "11:27:49")
.put("secret", "secret")
.put("array", "[1, 2, 3]")
.put("yaml", """
.put("yaml1", """
some: property
alist:
- of
- values""")
.put(
"yaml2",
Map.of(
"people",
Map.of(
"name1", List.of(
Map.of("first1", "Mustafa",
"last1", "Tarek")
),
"name2", List.of(
Map.of("first2", "Ahmed",
"last2", "Tarek")
)
)
)
)
.build();
@Inject
@@ -170,9 +187,24 @@ public class InputsTest {
assertThat(typeds.get("array")).isInstanceOf(List.class);
assertThat((List<Integer>) typeds.get("array")).hasSize(3);
assertThat((List<Integer>) typeds.get("array")).isEqualTo(List.of(1, 2, 3));
assertThat(typeds.get("yaml")).isEqualTo(Map.of(
assertThat(typeds.get("yaml1")).isEqualTo(Map.of(
"some", "property",
"alist", List.of("of", "values")));
assertThat(typeds.get("yaml2")).isEqualTo(Map.of(
"people",
Map.of(
"name1", List.of(
Map.of("first1", "Mustafa",
"last1", "Tarek")
),
"name2", List.of(
Map.of("first2", "Ahmed",
"last2", "Tarek")
)
)
));
}
@Test

View File

@@ -65,26 +65,6 @@ class SubflowRunnerTest {
new Label("parentFlowLabel2", "value2") // inherited from the parent flow
);
}
@Test
@LoadFlows({"flows/valids/subflow-serialized-yml-input-child.yaml", "flows/valids/subflow-serialized-yml-input-parent.yaml"})
void subflowInputTypeYmlSerialization() throws QueueException, TimeoutException {
Execution parentExecution = runnerUtils.runOne(MAIN_TENANT, "io.kestra.tests", "subflow-serialized-yml-input-parent");
String childExecutionId = (String) parentExecution.findTaskRunsByTaskId("hello1").getFirst().getOutputs().get("executionId");
assertThat(childExecutionId).isNotBlank();
Execution childExecution = executionRepository.findById(MAIN_TENANT, childExecutionId).orElseThrow();
assertThat(childExecution.getTaskRunList()).hasSize(2);
Map<?,?> outputs1 = (Map<?,?>) childExecution.outputs().get("hello2");
assertThat(outputs1.get("value"))
.isEqualTo("[{\"name1\":[{\"first1\":\"Mustafa\"},{\"last1\":\"Tarek\"}]},{\"name2\":[{\"first2\":\"Ahmed\"},{\"last2\":\"Tarek\"}]}]");
Map<?,?> outputs2 = (Map<?,?>) childExecution.outputs().get("hello3");
assertThat(outputs2.get("value")).isEqualTo("dummy");
}
@Test
@LoadFlows({"flows/valids/subflow-parent-no-wait.yaml", "flows/valids/subflow-child-with-output.yaml"})

View File

@@ -95,7 +95,7 @@ inputs:
- name: array
type: ARRAY
itemType: INT
- name: yaml
- name: yaml1
type: YAML
defaults:
property: something
@@ -104,6 +104,15 @@ inputs:
value: value1
- key: key2
value: value2
- name: yaml2
type: YAML
defaults:
property: something
list:
- key: key1
value: value1
- key: key2
value: value2
# required true and an empty default value will only work if we correctly serialize default values which is what this input is about to test.
- name: empty
type: STRING
@@ -146,6 +155,9 @@ tasks:
- id: jsonOutput
type: io.kestra.plugin.core.debug.Return
format: "{{outputs.json.value}}"
- id: yamlOutput
- id: yamlOutput1
type: io.kestra.plugin.core.debug.Return
format: "{{inputs.yaml}}"
format: "{{inputs.yaml1}}"
- id: yamlOutput2
type: io.kestra.plugin.core.debug.Return
format: "{{inputs.yaml2}}"

View File

@@ -1,16 +0,0 @@
id: subflow-serialized-yml-input-child
namespace: io.kestra.tests
inputs:
- id: people
type: YAML
- id: basic
type: YAML
tasks:
- id: hello2
type: io.kestra.plugin.core.debug.Return
format: "{{ inputs.people }}"
- id: hello3
type: io.kestra.plugin.core.debug.Return
format: "{{ inputs.basic }}"

View File

@@ -1,17 +0,0 @@
id: subflow-serialized-yml-input-parent
namespace: io.kestra.tests
tasks:
- id: hello1
type: io.kestra.plugin.core.flow.Subflow
namespace: io.kestra.tests
flowId: subflow-serialized-yml-input-child
inputs:
people:
- name1:
- first1: "Mustafa"
- last1: "Tarek"
- name2:
- first2: "Ahmed"
- last2: "Tarek"
basic: dummy