Add test for official plugins list being sorted

This commit is contained in:
Ryan Ernst 2016-05-25 14:21:33 -07:00
parent a9e7bdc54c
commit 5e7b8d7788
1 changed files with 25 additions and 0 deletions

View File

@ -36,8 +36,10 @@ import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.PosixPermissionsResetter;
import org.junit.After;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@ -532,6 +534,29 @@ public class InstallPluginCommandTests extends ESTestCase {
assertTrue(e.getMessage(), e.getMessage().contains("resolving outside of plugin directory"));
}
public void testOfficialPluginsHelpSorted() throws Exception {
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand().main(new String[] { "--help" }, terminal);
try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
String line = reader.readLine();
// first find the beginning of our list of official plugins
while (line.endsWith("may be installed by name:") == false) {
line = reader.readLine();
}
// now check each line compares greater than the last, until we reach an empty line
String prev = reader.readLine();
line = reader.readLine();
while (line != null && line.trim().isEmpty() == false) {
assertTrue(prev + " < " + line, prev.compareTo(line) < 0);
prev = line;
line = reader.readLine();
}
}
terminal.getOutput();
}
// TODO: test batch flag?
// TODO: test checksum (need maven/official below)
// TODO: test maven, official, and staging install...need tests with fixtures...