Convert ErrorIgnorer tests to doctests
This commit is contained in:
@@ -12,6 +12,29 @@ defmodule MusicLibrary.ErrorIgnorer do
|
|||||||
to_string(Phoenix.Router.NoRouteError)
|
to_string(Phoenix.Router.NoRouteError)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns `true` when the error kind should not be tracked.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> MusicLibrary.ErrorIgnorer.ignore?(
|
||||||
|
...> %ErrorTracker.Error{kind: "Elixir.Phoenix.Router.NoRouteError"},
|
||||||
|
...> %{}
|
||||||
|
...> )
|
||||||
|
true
|
||||||
|
|
||||||
|
iex> MusicLibrary.ErrorIgnorer.ignore?(
|
||||||
|
...> %ErrorTracker.Error{kind: "Elixir.RuntimeError"},
|
||||||
|
...> %{}
|
||||||
|
...> )
|
||||||
|
false
|
||||||
|
|
||||||
|
iex> MusicLibrary.ErrorIgnorer.ignore?(
|
||||||
|
...> %ErrorTracker.Error{kind: "Elixir.Ecto.NoResultsError"},
|
||||||
|
...> %{}
|
||||||
|
...> )
|
||||||
|
false
|
||||||
|
"""
|
||||||
@impl true
|
@impl true
|
||||||
def ignore?(%ErrorTracker.Error{kind: kind}, _context) when kind in @ignored_kinds, do: true
|
def ignore?(%ErrorTracker.Error{kind: kind}, _context) when kind in @ignored_kinds, do: true
|
||||||
def ignore?(_error, _context), do: false
|
def ignore?(_error, _context), do: false
|
||||||
|
|||||||
@@ -1,22 +1,5 @@
|
|||||||
defmodule MusicLibrary.ErrorIgnorerTest do
|
defmodule MusicLibrary.ErrorIgnorerTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
alias MusicLibrary.ErrorIgnorer
|
doctest MusicLibrary.ErrorIgnorer
|
||||||
|
|
||||||
describe "ignore?/2" do
|
|
||||||
test "ignores Phoenix.Router.NoRouteError" do
|
|
||||||
error = %ErrorTracker.Error{kind: "Elixir.Phoenix.Router.NoRouteError"}
|
|
||||||
assert ErrorIgnorer.ignore?(error, %{}) == true
|
|
||||||
end
|
|
||||||
|
|
||||||
test "does not ignore other error kinds" do
|
|
||||||
error = %ErrorTracker.Error{kind: "Elixir.RuntimeError"}
|
|
||||||
assert ErrorIgnorer.ignore?(error, %{}) == false
|
|
||||||
end
|
|
||||||
|
|
||||||
test "does not ignore Ecto.NoResultsError" do
|
|
||||||
error = %ErrorTracker.Error{kind: "Elixir.Ecto.NoResultsError"}
|
|
||||||
assert ErrorIgnorer.ignore?(error, %{}) == false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user