github: Rename `get_review_comment` in `get_pull_comment`
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 11 Jul 2019 00:57:08 +0000 (20:57 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 11 Jul 2019 02:07:02 +0000 (22:07 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/github/api.nit
lib/github/tests/test_api.nit

index 901ec6a..bb98665 100644 (file)
@@ -369,6 +369,11 @@ class GithubAPI
                return get("/repos/{repo_slug}/pulls/{number}").as(nullable PullRequest)
        end
 
+       # Get a specific pull request comment
+       fun get_pull_comment(repo_slug: String, id: Int): nullable ReviewComment do
+               return get("/repos/{repo_slug}/pulls/comments/{id}").as(nullable ReviewComment)
+       end
+
        # Get the Github label with `name`.
        #
        # Returns `null` if the label cannot be found.
@@ -452,23 +457,6 @@ class GithubAPI
                return get("/repos/{repo_slug}/issues/comments/{id}").as(nullable IssueComment)
        end
 
-       # Get the Github diff comment with `id`.
-       #
-       # Returns `null` if the comment cannot be found.
-       #
-       # ~~~nitish
-       # var api = new GithubAPI(get_github_oauth)
-       # var repo = api.get_repo("nitlang/nit")
-       # assert repo != null
-       # var comment = api.get_review_comment(repo, 21010363)
-       # assert comment.path == "src/modelize/modelize_property.nit"
-       # assert comment.original_position == 26
-       # assert comment.pull_number == 945
-       # ~~~
-       fun get_review_comment(repo_slug: String, id: Int): nullable ReviewComment do
-               return get("/repos/{repo_slug}/pulls/comments/{id}").as(nullable ReviewComment)
-       end
-
        private fun pagination(page, per_page: nullable Int): String do
                return "page={page or else 1}&per_page={per_page or else 30}"
        end
index d130052..89d6960 100644 (file)
@@ -336,6 +336,15 @@ class TestGithubAPI
                assert pull.body == "Raise dead on `nitc`.\nIt's super effective...\n"
        end
 
+       fun test_get_pull_comment is test do
+               var comment = api.get_pull_comment("nitlang/nit", 21010363)
+               assert comment isa ReviewComment
+               assert comment.path == "src/modelize/modelize_property.nit"
+               assert comment.original_position == 26
+               assert comment.pull_number == 945
+               # TODO other fields
+       end
+
        fun test_get_label is test do
                var labl = api.get_label("nitlang/nit", "ok_will_merge")
                assert labl isa Label
@@ -372,12 +381,4 @@ class TestGithubAPI
                assert comment.body == "For testing purposes...\n"
                assert comment.commit_id == "7eacb86d1e24b7e72bc9ac869bf7182c0300ceca"
        end
-
-       fun test_get_review_comments is test do
-               var comment = api.get_review_comment("nitlang/nit", 21010363)
-               assert comment isa ReviewComment
-               assert comment.path == "src/modelize/modelize_property.nit"
-               assert comment.original_position == 26
-               assert comment.pull_number == 945
-       end
 end