Skip to content

Commit

Permalink
Ajout test pour erreur HTTP 500
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed Oct 20, 2021
1 parent df75f24 commit d7d083c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion apps/gbfs/test/gbfs/controllers/smoove_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule GBFS.SmooveControllerTest do
use GBFS.ConnCase, async: false
alias GBFS.Router.Helpers, as: Routes
use GBFS.ExternalCase
# import Mock
import Mock
import GBFS.Checker

describe "Smoove GBFS conversion" do
Expand Down Expand Up @@ -33,5 +33,20 @@ defmodule GBFS.SmooveControllerTest do
check_station_status(body)
end
end

test "on invalid response", %{conn: conn} do
mock = fn url ->
if String.match?(url, ~r|TAM_MMM_VELOMAG.xml$|) do
{:ok, %HTTPoison.Response{body: "{}", status_code: 500}}
end
end

with_mock HTTPoison, get: mock do
conn = conn |> get(Routes.montpellier_path(conn, :station_status))
assert %{"error" => "smoove service unavailable"} == json_response(conn, 502)

assert_called_exactly(HTTPoison.get(:_), 1)
end
end
end
end

0 comments on commit d7d083c

Please sign in to comment.