Skip to content
Closed
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 @@ -37,9 +37,10 @@ public void testCamelListConfig() {
execute("config set runtime=quarkus");
execute("config set directory=" + mountPoint());
checkCommandOutputs("config list",
"gav = com.foo:acme:1.0-SNAPSHOT\n" +
"runtime = quarkus\n" +
"directory = " + mountPoint());
new String[] {
"gav = com.foo:acme:1.0-SNAPSHOT",
"runtime = quarkus",
"directory = " + mountPoint() });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Compilation error: checkCommandOutputs(String, String) does not have an overload accepting String[]. This code won't compile.

Since the existing checkCommandOutputs only takes a single String, you'll need to either add a varargs overload in JBangTestSupport or check each line individually.

Suggested varargs overload for JBangTestSupport:

protected void checkCommandOutputs(String command, String... contains) {
    String output = execute(command);
    for (String c : contains) {
        Assertions.assertThat(output)
                .as("command " + getMainCommand() + " " + command + " should output " + c)
                .contains(c);
    }
}

Note: changing the existing (String, String) signature to (String, String...) is source-compatible — all existing callers pass a single string which matches the varargs.

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ protected void checkCommandOutputs(String command, String contains) {
.contains(contains);
}

protected void checkCommandOutputs(String command, String... contains) {
Assertions.assertThat(execute(command))
.as("command " + getMainCommand() + " " + command + " should output each of these lines " + contains)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two nits:

  1. + contains+ java.util.Arrays.toString(contains) (otherwise this prints [Ljava.lang.String;@hash)
  2. Double space: "command ""command "
Suggested change
.as("command " + getMainCommand() + " " + command + " should output each of these lines " + contains)
protected void checkCommandOutputs(String command, String... contains) {
Assertions.assertThat(execute(command))
.as("command " + getMainCommand() + " " + command + " should output each of these lines " + java.util.Arrays.toString(contains))
.contains(contains);
}

.contains(contains);
}

protected void checkCommandFailsWithError(String command, String error) {
Assertions.assertThat(execute(command, true, true))
.as("command " + getMainCommand() + " " + command + " should fail with error " + error)
Expand Down