Skip to content

Commit

Permalink
Charts disabled plug testing
Browse files Browse the repository at this point in the history
  • Loading branch information
CDimonaco committed Jan 8, 2024
1 parent 0bd9da5 commit a7451c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/trento_web/plugs/charts_disabled_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule TrentoWeb.Plugs.ChartsDisabledPlug do
@spec call(Plug.Conn.t(), any) :: Plug.Conn.t()
def call(conn, _) do
conn
|> put_status(501)
|> put_resp_content_type("application/json")
|> resp(
501,
Jason.encode!(
Expand Down
22 changes: 22 additions & 0 deletions test/trento_web/plugs/charts_disabled_plug_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule TrentoWeb.Plugs.ChartsDisabledPlugTest do
use TrentoWeb.ConnCase, async: true
use Plug.Test

alias TrentoWeb.Plugs.ChartsDisabledPlug

test "should return 501 when called" do
conn = conn(:get, "/foo")

conn = ChartsDisabledPlug.call(conn, [])

assert %{
"errors" => [
%{
"detail" =>
"Charts endpoints are disabled, check the documentation for further details",
"title" => "Not implemented"
}
]
} = json_response(conn, 501)
end
end

0 comments on commit a7451c4

Please sign in to comment.