Skip to content
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 @@ -106,6 +106,7 @@ public ScriptOutput run(RunContext runContext) throws Exception {
.withBeforeCommands(Property.ofValue(List.of("alias cloudquery='/app/cloudquery'")))
.withCommands(this.commands)
.withEnv(runContext.render(this.getEnv()).asMap(String.class, String.class).isEmpty() ? new HashMap<>() : runContext.render(this.getEnv()).asMap(String.class, String.class))
.withNamespaceFiles(namespaceFiles)
Comment thread
Pavani3001 marked this conversation as resolved.
.withInputFiles(inputFiles)
.withOutputFiles(renderedOutputFiles.isEmpty() ? null : renderedOutputFiles);

Expand Down
30 changes: 29 additions & 1 deletion src/test/java/io/kestra/plugin/cloudquery/CloudQueryCLITest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.kestra.plugin.cloudquery;

import java.io.ByteArrayInputStream;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;

Expand All @@ -8,6 +10,7 @@

import io.kestra.core.junit.annotations.KestraTest;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.NamespaceFiles;
import io.kestra.core.runners.RunContext;
import io.kestra.core.runners.RunContextFactory;
import io.kestra.core.utils.IdUtils;
Expand Down Expand Up @@ -55,4 +58,29 @@ void run() throws Exception {
assertThat(runOutput.getVars().get("customEnv"), is(envValue));

}
}

@Test
void namespaceFiles() throws Exception {
CloudQueryCLI execute = CloudQueryCLI.builder()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 [Guidelines] Use var for locals in the new test
Problem: The new namespaceFiles test declares CloudQueryCLI execute, RunContext runContext and ScriptOutput runOutput with explicit types, while the Java Style & Local Variables section asks for var on all local variables where it is legal.
Fix: Write var execute = CloudQueryCLI.builder()..., var runContext = TestsUtils.mockRunContext(...) and var runOutput = execute.run(runContext). Optional.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will cross check and fix it

.id(IdUtils.create())
.type(CloudQueryCLI.class.getName())
.namespaceFiles(
NamespaceFiles.builder()
.enabled(Property.ofValue(true))
.build()
)
.commands(Property.ofValue(List.of("test -f config.yml")))
.build();

RunContext runContext = TestsUtils.mockRunContext(runContextFactory, execute, Map.of());

runContext.storage().namespace().putFile(
Path.of("config.yml"),
new ByteArrayInputStream("kind: source".getBytes())
);

ScriptOutput runOutput = execute.run(runContext);

assertThat(runOutput.getExitCode(), is(0));
}
}
Loading