You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2023/01/17 16:09:08 UTC

[GitHub] [ignite-3] Flaugh24 commented on a diff in pull request #1502: IGNITE-18491: Add tests for completers

Flaugh24 commented on code in PR #1502:
URL: https://github.com/apache/ignite-3/pull/1502#discussion_r1072405500


##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", ""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", ""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given

Review Comment:
   done



##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/core/repl/executor/ItIgnitePicocliCommandsTest.java:
##########
@@ -356,6 +359,76 @@ void startStopNodeWhenCompleteNodeName() {
         await().until(() -> complete(givenParsedLine), containsInAnyOrder(allNodeNames().toArray()));
     }
 
+    @Test
+    @DisplayName("jdbc url suggested after --jdbc-url option")
+    void suggestedJdbcUrl() {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> jdbcUrlRegistry.jdbcUrls(), not(empty()));
+
+        // Then
+        List<String> completions = complete(words("sql", "--jdbc-url", ""));
+        assertThat(completions, containsInAnyOrder(jdbcUrlRegistry.jdbcUrls().toArray()));
+    }
+
+    private Stream<Arguments> clusterUrlSource() {
+        return Stream.of(
+                words("cluster", "config", "show", "--cluster-endpoint-url", ""),
+                words("cluster", "config", "update", "--cluster-endpoint-url", ""),
+                words("cluster", "status", "--cluster-endpoint-url", ""),
+                words("cluster", "init", "--cluster-endpoint-url", "")
+        ).map(this::named).map(Arguments::of);
+    }
+
+    @ParameterizedTest
+    @MethodSource("clusterUrlSource")
+    @DisplayName("cluster url suggested after --cluster-endpoint-url option")
+    void suggestedClusterUrl(ParsedLine parsedLine) {
+        // Given
+        connected();
+        // And the first update is fetched
+        await().until(() -> nodeNameRegistry.urls(), not(empty()));
+
+        // Then
+        String[] expectedUrls = nodeNameRegistry.urls().stream().map(URL::toString).toArray(String[]::new);
+        assertThat("For given parsed words: " + parsedLine.words(),
+                complete(parsedLine),
+                containsInAnyOrder(expectedUrls));
+    }
+
+    @Test
+    @DisplayName("files suggested after -script-file option")
+    void suggestedScriptFile() {
+
+        // Given
+
+        // Create temp folder
+        File folder = Files.newTemporaryFolder();
+
+        // Create temp files
+        String script1 = folder.getPath() + File.separator + "script1.sql";
+        Files.newFile(script1).deleteOnExit();
+
+        String script2 = folder.getPath() + File.separator + "script2.sql";
+        Files.newFile(script2).deleteOnExit();
+
+        String someFile = folder.getPath() + File.separator + "someFile.sql";
+        Files.newFile(someFile).deleteOnExit();
+
+        // Then
+
+        // Search in the folder
+        List<String> completions1 = complete(words("sql", "--script-file", folder.getPath()));
+        // Contains all files
+        assertThat(completions1, contains(script1, script2, someFile));
+
+        // Search in the folder for files which starts with 'scrpit'
+        List<String> completions2 = complete(words("sql", "--script-file", folder.getPath() + File.separator + "script"));

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org