Test Fixes

This commit is contained in:
Katelyn Baker 2018-05-11 14:44:17 +01:00
parent df68fa1a5e
commit c5591defe3
3 changed files with 9 additions and 8 deletions

View File

@ -25,15 +25,16 @@ class DoormanArgsParserTest {
@Test @Test
fun `should fail when network parameters file is missing`() { fun `should fail when network parameters file is missing`() {
assertThatThrownBy { assertThatThrownBy {
argsParser.parseOrExit("--config-file", validConfigPath, "--set-network-parameters", "not-here") argsParser.parseOrExit("--config-file", validConfigPath, "--set-network-parameters", "not-here",
printHelpOn = null)
}.hasMessageContaining("not-here") }.hasMessageContaining("not-here")
} }
@Test @Test
fun `should fail when config file is missing`() { fun `should fail when config file is missing`() {
assertThatThrownBy { assertThatThrownBy {
argsParser.parseOrExit("--config-file", "not-existing-file") argsParser.parseOrExit("--config-file", "not-existing-file", printHelpOn = null)
}.hasMessageContaining("not-existing-file") }.hasMessageContaining("Specified config file doesn't exist")
} }
@Test @Test
@ -41,16 +42,16 @@ class DoormanArgsParserTest {
val parameter = argsParser.parseOrExit("--config-file", validConfigPath, "--mode", "ROOT_KEYGEN", "--trust-store-password", "testPassword") val parameter = argsParser.parseOrExit("--config-file", validConfigPath, "--mode", "ROOT_KEYGEN", "--trust-store-password", "testPassword")
assertEquals("testPassword", parameter.trustStorePassword) assertEquals("testPassword", parameter.trustStorePassword)
assertFailsWith<OptionException> { assertFailsWith<RuntimeException> {
argsParser.parseOrExit("--trust-store-password", printHelpOn = null) argsParser.parseOrExit("--trust-store-password", printHelpOn = null)
} }
// Should fail if password is provided in mode other then root keygen. // Should fail if password is provided in mode other then root keygen.
assertFailsWith<IllegalArgumentException> { assertFailsWith<IllegalArgumentException> {
argsParser.parseOrExit("--config-file", validConfigPath, "--trust-store-password", "testPassword") argsParser.parseOrExit("--config-file", validConfigPath, "--trust-store-password", "testPassword", printHelpOn = null)
} }
// trust store password is optional. // trust store password is optional.
assertNull(argsParser.parseOrExit("--config-file", validConfigPath).trustStorePassword) assertNull(argsParser.parseOrExit("--config-file", validConfigPath, printHelpOn = null).trustStorePassword)
} }
} }

View File

@ -51,7 +51,7 @@ class SigningServiceArgsParserTest : TestBase() {
@Test @Test
fun `should fail when config file is missing`() { fun `should fail when config file is missing`() {
assertThatThrownBy { assertThatThrownBy {
argsParser.parseOrExit("--config-file", "not-existing-file") argsParser.parseOrExit("--config-file", "not-existing-file", printHelpOn = null)
}.hasMessageContaining("not-existing-file") }.hasMessageContaining("not-existing-file")
} }
} }

View File

@ -30,7 +30,7 @@ class GeneratorParametersTest {
@Test @Test
fun `should fail when config file is missing`() { fun `should fail when config file is missing`() {
val message = assertFailsWith<OptionException> { val message = assertFailsWith<OptionException> {
ConfigFilePathArgsParser().parseOrExit("--config-file", "not-existing-file") ConfigFilePathArgsParser().parseOrExit("--config-file", "not-existing-file", printHelpOn = null)
}.message }.message
Assertions.assertThat(message).contains("not-existing-file") Assertions.assertThat(message).contains("not-existing-file")
} }