Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
[NC-2094] Tests that cli options are disabled under docker, and that …
Browse files Browse the repository at this point in the history
…datadir defaults (#566)
  • Loading branch information
Errorific authored Jan 16, 2019
1 parent 633dfb1 commit ab45103
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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;
Expand Down Expand Up @@ -422,6 +423,18 @@ public void noOverrideDefaultValuesIfKeyIsNotPresentInConfigFile() throws IOExce
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");
Expand Down Expand Up @@ -458,6 +471,31 @@ public void dataDirOptionMustBeUsed() throws Exception {
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());
Expand All @@ -477,6 +515,19 @@ public void genesisPathOptionMustBeUsed() throws Exception {
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");
Expand Down

0 comments on commit ab45103

Please sign in to comment.