From ab45103f5eb10ed25d39d18dea937c13f71e70c6 Mon Sep 17 00:00:00 2001 From: Chris Mckay Date: Wed, 16 Jan 2019 11:53:02 +1000 Subject: [PATCH] [NC-2094] Tests that cli options are disabled under docker, and that datadir defaults (#566) --- .../pantheon/cli/PantheonCommandTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java index 7247b693fc..74b726cea9 100644 --- a/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java +++ b/pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java @@ -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; @@ -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"); @@ -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()); @@ -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");