Skip to content

Commit

Permalink
Added an additional test for --help in neo4j-admin
Browse files Browse the repository at this point in the history
and made code slightly more robust to avoid nullpointerexceptions
  • Loading branch information
spacecowboy committed Mar 28, 2017
1 parent d8f2b5e commit 58a29fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -105,6 +105,12 @@ public void execute( Path homeDir, Path configDir, String... args )
return;
}

if ( provider == null )
{
badUsage( format( "unrecognized command: %s", name ) );
return;
}

if ( Args.parse( commandArgs ).has( "help" ) )
{
outsideWorld.stdErrLine( "unknown argument: --help" );
Expand Down
Expand Up @@ -245,7 +245,22 @@ public void shouldNotBlockIfNoneOfTheBlockersBlock() throws CommandFailed, Incor
}

@Test
public void helpArgumentShouldAlwaysPrintHelp() throws CommandFailed, IncorrectUsage
public void helpArgumentPrintsHelp() throws CommandFailed, IncorrectUsage
{
AdminCommand command = mock( AdminCommand.class );
OutsideWorld outsideWorld = mock( OutsideWorld.class );

new AdminTool( cannedCommand( "command", command ), new NullBlockerLocator(), outsideWorld, false )
.execute( null, null, "--help" );

verifyNoMoreInteractions( command );
verify( outsideWorld ).stdErrLine( "unrecognized command: --help" );
verify( outsideWorld ).stdErrLine( "usage: neo4j-admin <command>" );
verify( outsideWorld ).exit( STATUS_ERROR );
}

@Test
public void helpArgumentPrintsHelpForCommand() throws CommandFailed, IncorrectUsage
{
AdminCommand command = mock( AdminCommand.class );
OutsideWorld outsideWorld = mock( OutsideWorld.class );
Expand Down

0 comments on commit 58a29fb

Please sign in to comment.