Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Survive coveralls maintenance and outagle #283

Merged
merged 2 commits into from Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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