From 5e7b8d7788b659d6ae41ad8c41efb794739b521a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 25 May 2016 14:21:33 -0700 Subject: [PATCH] Add test for official plugins list being sorted --- .../plugins/InstallPluginCommandTests.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java index 22b2ef39a88..14910ffcdeb 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java @@ -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...