Added opton to add a List via the command method

This commit is contained in:
Erik C. Thauvin 2023-08-27 16:46:47 -07:00
parent 9843cfeb6b
commit 193c791408
6 changed files with 44 additions and 8 deletions

View file

@ -23,6 +23,7 @@ import rife.bld.WebProject;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
@ -30,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
class ExecOperationTest {
private static final String FOO = "foo";
private static final String HELLO = "Hello";
@Test
void testAll() {
@ -55,6 +57,16 @@ class ExecOperationTest {
assertThat(tmpFile).exists();
}
@Test
void testCommandList() {
assertThatCode(() ->
new ExecOperation()
.fromProject(new BaseProject())
.command(List.of("logger", "-s", HELLO))
.fail(ExecFail.STDERR)
.execute()).message().startsWith("STDERR -> ").endsWith(HELLO);
}
@Test
void testException() {
assertThatCode(() ->
@ -100,9 +112,9 @@ class ExecOperationTest {
assertThatCode(() ->
new ExecOperation()
.fromProject(new BaseProject())
.command("logger", "-s", "Hello")
.command("logger", "-s", HELLO)
.fail(ExecFail.STDERR)
.execute()).message().startsWith("STDERR -> ").endsWith("Hello");
.execute()).message().startsWith("STDERR -> ").endsWith(HELLO);
}
@Test
@ -110,7 +122,7 @@ class ExecOperationTest {
assertThatCode(() ->
new ExecOperation()
.fromProject(new BaseProject())
.command("echo", "Hello")
.command("echo", HELLO)
.fail(ExecFail.STDOUT)
.execute()).message().isEqualTo("STDOUT -> Hello");
}