Skip to content

Commit ea306be

Browse files
committed
test: comments service
1 parent f88e618 commit ea306be

File tree

2 files changed

+632
-2
lines changed

2 files changed

+632
-2
lines changed

lib/opencov/services/github/comments.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ defmodule Librecov.Services.Github.Comments do
1313
case token |> PullRequests.find_prs_for_branch(owner, repo, branch) do
1414
{:ok, []} ->
1515
Logger.info("No pull requests found for branch #{branch}")
16+
{:error, :pr_not_found}
1617

1718
{:ok, prs} when is_list(prs) ->
18-
prs |> Enum.each(&add_pr_message(token, pr_message, &1))
19+
{:ok, prs |> Enum.map(&add_pr_message(token, pr_message, &1))}
1920

2021
{_, e} when is_exception(e) ->
2122
Logger.error(e |> Exception.message())
2223
Sentry.capture_exception(e)
24+
{:error, e}
2325

2426
{_, %{message: message}} ->
2527
Logger.error(message)
@@ -29,6 +31,7 @@ defmodule Librecov.Services.Github.Comments do
2931
)
3032

3133
e ->
34+
IO.inspect(e)
3235
raise(
3336
"Error processing add_pr_comment(pr_message, #{token}, #{owner}, #{repo}, #{branch})."
3437
)
@@ -41,13 +44,15 @@ defmodule Librecov.Services.Github.Comments do
4144
}) do
4245
Logger.info("Sending pr_message to #{owner}/#{repo}##{issue_number}.")
4346

44-
{:ok, %{id: id}} =
47+
{:ok, %{id: id} = comment} =
4548
token
4649
|> Connection.new()
4750
|> Issues.issues_create_comment(owner, repo, issue_number, body: %{body: pr_message})
4851

4952
Logger.info(
5053
"Succesfully sent message to #{owner}/#{repo}##{issue_number}. IssueComment##{id}"
5154
)
55+
56+
comment
5257
end
5358
end

0 commit comments

Comments
 (0)