use of io.kestra.core.tasks.scripts.Node in project kestra by kestra-io.
the class NodeTest method run.
@Test
void run() throws Exception {
RunContext runContext = runContextFactory.of();
Map<String, String> files = new HashMap<>();
files.put("main.js", "console.log('::{\"outputs\": {\"extract\":\"hello world\"}}::')");
Node node = Node.builder().id("test-node-task").nodePath("node").inputFiles(files).build();
ScriptOutput run = node.run(runContext);
assertThat(run.getExitCode(), is(0));
assertThat(run.getStdOutLineCount(), is(1));
assertThat(run.getVars().get("extract"), is("hello world"));
assertThat(run.getStdErrLineCount(), equalTo(0));
}
use of io.kestra.core.tasks.scripts.Node in project kestra by kestra-io.
the class NodeTest method manyFiles.
@Test
void manyFiles() throws Exception {
RunContext runContext = runContextFactory.of();
Map<String, String> files = new HashMap<>();
files.put("main.js", "console.log('::{\"outputs\": {\"extract\":\"' + (require('./otherfile').value) + '\"}}::')");
files.put("otherfile.js", "module.exports.value = 'success'");
Node node = Node.builder().id("test-node-task").nodePath("node").inputFiles(files).build();
ScriptOutput run = node.run(runContext);
assertThat(run.getExitCode(), is(0));
assertThat(run.getVars().get("extract"), is("success"));
}
Aggregations