Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Teach the CLI to ignore empty commands #30265

Merged
merged 2 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public void execute() {
multiLine.setLength(0);
}

// Skip empty commands
if (line.isEmpty()) {
continue;
}

// special case to handle exit
if (isExit(line)) {
cliTerminal.line().em("Bye!").ln();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ public void testBasicCliFunctionality() throws Exception {
verifyNoMoreInteractions(mockCommand, mockSession);
}

/**
* Test that empty commands are skipped. This includes commands that are
* just new lines.
*/
public void testEmptyNotSent() {
CliTerminal cliTerminal = new TestTerminal(
";",
"",
"",
";",
"exit;"
);

CliSession mockSession = mock(CliSession.class);
CliCommand mockCommand = mock(CliCommand.class);

CliRepl cli = new CliRepl(cliTerminal, mockSession, mockCommand);
cli.execute();

verify(mockCommand, times(1)).handle(cliTerminal, mockSession, "logo");
verifyNoMoreInteractions(mockSession, mockCommand);
}

public void testFatalCliExceptionHandling() throws Exception {
CliTerminal cliTerminal = new TestTerminal(
Expand Down