Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crbelaus committed Sep 6, 2024
1 parent 5042002 commit e51959a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions test/error_tracker/ignorer_test.exs
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
defmodule ErrorTracker.IgnorerTest do
use ErrorTracker.Test.Case

setup_all do
Application.put_env(:error_tracker, :ignorer, ErrorTracker.EveryErrorIgnorer)
setup context do
if ignorer = context[:ignorer] do
previous_setting = Application.get_env(:error_tracker, :ignorer)
Application.put_env(:error_tracker, :ignorer, ignorer)
# Ensure that the application env is restored after each test
on_exit(fn -> Application.put_env(:error_tracker, :ignorer, previous_setting) end)
end

[]
end

test "ignores errors" do
@tag ignorer: ErrorTracker.EveryErrorIgnorer
test "with an ignorer ignores errors" do
refute report_error(fn -> raise "[IGNORE] Sample error" end)
assert report_error(fn -> raise "Sample error" end)
end

@tag ignorer: false
test "without an ignorer does not ignore errors" do
assert report_error(fn -> raise "[IGNORE] Sample error" end)
assert report_error(fn -> raise "Sample error" end)
end
end

defmodule ErrorTracker.EveryErrorIgnorer do
Expand Down

0 comments on commit e51959a

Please sign in to comment.