[NC-2094] Tests that cli options are disabled under docker, and that datadir defaults (#566)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Chris Mckay 6 years ago committed by GitHub
parent 45c1491414
commit c212205f9f
  1. 51
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java

@ -15,6 +15,7 @@ package tech.pegasys.pantheon.cli;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
@ -422,6 +423,18 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void configOptionDisabledUnderDocker() {
System.setProperty("pantheon.docker", "true");
assumeFalse(isFullInstantiation());
final Path path = Paths.get(".");
parseCommand("--config", path.toString());
assertThat(commandErrorOutput.toString()).startsWith("Unknown options: --config, .");
assertThat(commandOutput.toString()).isEmpty();
}
@Test
public void nodekeyOptionMustBeUsed() throws Exception {
final File file = new File("./specific/key");
@ -458,6 +471,31 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void dataDirDisabledUnderDocker() {
System.setProperty("pantheon.docker", "true");
assumeFalse(isFullInstantiation());
final Path path = Paths.get(".");
parseCommand("--datadir", path.toString());
assertThat(commandErrorOutput.toString()).startsWith("Unknown options: --datadir, .");
assertThat(commandOutput.toString()).isEmpty();
}
@Test
public void dataDirDefaultedUnderDocker() {
System.setProperty("pantheon.docker", "true");
assumeFalse(isFullInstantiation());
parseCommand();
verify(mockControllerBuilder).homePath(pathArgumentCaptor.capture());
assertThat(pathArgumentCaptor.getValue()).isEqualByComparingTo(Paths.get("/var/lib/pantheon"));
}
@Test
public void genesisPathOptionMustBeUsed() throws Exception {
assumeTrue(isFullInstantiation());
@ -477,6 +515,19 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void genesisPathDisabledUnderDocker() {
System.setProperty("pantheon.docker", "true");
assumeFalse(isFullInstantiation());
final Path path = Paths.get(".");
parseCommand("--genesis", path.toString());
assertThat(commandErrorOutput.toString()).startsWith("Unknown options: --genesis, .");
assertThat(commandOutput.toString()).isEmpty();
}
@Test
public void discoveryOptionMustBeUsed() {
parseCommand("--no-discovery");

Loading…
Cancel
Save