You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/11/05 11:52:13 UTC

[GitHub] [shardingsphere] Jacob953 commented on a diff in pull request #21969: Add openGauss for DynamicLoadingSQLParserParameterizedTest

Jacob953 commented on code in PR #21969:
URL: https://github.com/apache/shardingsphere/pull/21969#discussion_r1014625425


##########
test/parser/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/engine/DynamicLoadingSQLParserParameterizedTest.java:
##########
@@ -68,17 +70,32 @@ private static Collection<Map<String, String>> getResponse(final String sqlCaseU
         String casesGitHubApiContent = getContent(casesGitHubApiURL);
         List<String> casesName = JsonPath.parse(casesGitHubApiContent).read("$..name");
         List<String> casesDownloadURL = JsonPath.parse(casesGitHubApiContent).read("$..download_url");
+        List<String> casesHtmlURL = JsonPath.parse(casesGitHubApiContent).read("$..html_url");
         IntStream.range(0, JsonPath.parse(casesGitHubApiContent).read("$.length()"))
-                .forEach(each -> result.add(ImmutableMap.of("name", casesName.get(each), "download_url", casesDownloadURL.get(each))));
+                .forEach(each -> {
+                    String eachName = casesName.get(each);
+                    if (eachName.endsWith(".sql") || eachName.endsWith(".test")) {
+                        result.add(ImmutableMap.of("name", eachName, "download_url", casesDownloadURL.get(each)));
+                    } else if (!eachName.contains(".")) {
+                        result.addAll(getResponse(casesHtmlURL.get(each)));
+                    }
+                });
         return result;
     }
     
-    private static String getContent(final String url) throws IOException {
-        InputStreamReader in = new InputStreamReader(new URL(url).openStream());
-        return new BufferedReader(in).lines().collect(Collectors.joining(System.lineSeparator()));
+    private static String getContent(final String url) {
+        String result = "";
+        try {
+            InputStreamReader in = new InputStreamReader(new URL(url).openStream());
+            result = new BufferedReader(in).lines().collect(Collectors.joining(System.lineSeparator()));
+        } catch (IOException ingore) {
+            log.warn("Error: GitHub API rate limit exceeded");
+            System.exit(0);

Review Comment:
   The empty string will fail when getTestParameters pass params to assertParseSQL, since it doesn't match.
   
   How about returning `name: null download_url: null`? like [this](https://github.com/apache/shardingsphere/pull/21969/commits/865314d75e48a15186386e16a6b8513a1a97da81#diff-fa0800d30c019c7606917c470cb08892e3eec497dc46fe111e267646fd9b4721R71).



-- 
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@shardingsphere.apache.org

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