From 1d3d1c38859f58137c9fd523dc60819ce4ca6f0b Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Wed, 10 Jul 2019 20:57:08 -0400 Subject: [PATCH] github: Rename `get_review_comment` in `get_pull_comment` Signed-off-by: Alexandre Terrasa --- lib/github/api.nit | 22 +++++----------------- lib/github/tests/test_api.nit | 17 +++++++++-------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/lib/github/api.nit b/lib/github/api.nit index 901ec6a..bb98665 100644 --- a/lib/github/api.nit +++ b/lib/github/api.nit @@ -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 diff --git a/lib/github/tests/test_api.nit b/lib/github/tests/test_api.nit index d130052..89d6960 100644 --- a/lib/github/tests/test_api.nit +++ b/lib/github/tests/test_api.nit @@ -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 -- 1.7.9.5