Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 913e1a6

Browse files
author
Prem Sichanugrist
committed
Make GithubPullRequest able to handle error status
1 parent 5a2a4a3 commit 913e1a6

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/cc/services/github_pull_requests.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ def receive_pull_request
6363
when "success"
6464
add_comment
6565
update_status("success", "Code Climate has analyzed this pull request.")
66+
when "error"
67+
update_status(
68+
"error",
69+
"Code Climate encountered an error while attempting to analyze this " +
70+
"pull request."
71+
)
6672
end
6773
end
6874

test/github_pull_requests_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ def test_pull_request_status_success
2727
})
2828
end
2929

30+
def test_pull_request_status_error
31+
expect_status_update("pbrisbin/foo", "abc123", {
32+
"state" => "error",
33+
"description" => /encountered an error/,
34+
})
35+
36+
receive_pull_request({ update_status: true }, {
37+
github_slug: "pbrisbin/foo",
38+
commit_sha: "abc123",
39+
state: "error",
40+
})
41+
42+
end
43+
3044
def test_pull_request_status_test_success
3145
@stubs.post("/repos/pbrisbin/foo/statuses/#{"0" * 40}") { |env| [422, {}, ""] }
3246

0 commit comments

Comments
 (0)