Skip to content

Commit

Permalink
Merge pull request #283 from tgrk/survive-coveralls-maintenance
Browse files Browse the repository at this point in the history
Survive coveralls maintenance and outagle
  • Loading branch information
parroty committed Jul 11, 2022
2 parents a215645 + f845177 commit e662725
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/excoveralls/poster.ex
Expand Up @@ -43,6 +43,10 @@ defmodule ExCoveralls.Poster do
{:ok, status_code, _, _} when status_code in 200..299 ->
{:ok, "Successfully uploaded the report to '#{endpoint}'."}

{:ok, 500 = _status_code, _, _client} ->
{:ok, "API endpoint `#{endpoint}` is not available and return internal server error! Ignoring upload"}
{:ok, 405 = _status_code, _, _client} ->
{:ok, "API endpoint `#{endpoint}` is not available due to maintenance! Ignoring upload"}
{:ok, status_code, _, client} ->
{:ok, body} = :hackney.body(client)

Expand Down
12 changes: 12 additions & 0 deletions test/poster_test.exs
Expand Up @@ -21,4 +21,16 @@ defmodule PosterTest do
assert ExCoveralls.Poster.execute("json") == :ok
end) =~ ~r/timeout/
end

test_with_mock "post json fails due internal server error", :hackney, [request: fn(_, _, _, _, _) -> {:ok, 500, "", ""} end] do
assert capture_io(fn ->
assert ExCoveralls.Poster.execute("json") == :ok
end) =~ ~r/internal server error/
end

test_with_mock "post json fails due to maintenance", :hackney, [request: fn(_, _, _, _, _) -> {:ok, 405, "", ""} end] do
assert capture_io(fn ->
assert ExCoveralls.Poster.execute("json") == :ok
end) =~ ~r/maintenance/
end
end

0 comments on commit e662725

Please sign in to comment.