giant massive dep upgrade and dialyxir-found error emporium (#371)
[akkoma] / test / pleroma / web / views / error_view_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ErrorViewTest do
6 use Pleroma.Web.ConnCase, async: true
7 import ExUnit.CaptureLog
8
9 # Bring render/3 and render_to_string/3 for testing custom views
10 import Phoenix.View
11
12 test "renders 404.json" do
13 assert render(Pleroma.Web.ErrorView, "404.json", []) == %{errors: %{detail: "Page not found"}}
14 end
15
16 test "render 500.json" do
17 assert capture_log(fn ->
18 assert render(Pleroma.Web.ErrorView, "500.json", []) ==
19 %{errors: %{detail: "Internal server error", reason: "nil"}}
20 end) =~ "[error] Internal server error: nil"
21 end
22
23 test "render any other" do
24 assert capture_log(fn ->
25 assert render(Pleroma.Web.ErrorView, "505.json", []) ==
26 %{errors: %{detail: "Internal server error", reason: "nil"}}
27 end) =~ "[error] Internal server error: nil"
28 end
29
30 test "render 500.json with reason" do
31 assert capture_log(fn ->
32 assert render(Pleroma.Web.ErrorView, "500.json", reason: "test reason") ==
33 %{errors: %{detail: "Internal server error", reason: "\"test reason\""}}
34 end) =~ "[error] Internal server error: \"test reason\""
35 end
36 end