Skip to content

Commit e51959a

Browse files
committed
Improve tests
1 parent 5042002 commit e51959a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test/error_tracker/ignorer_test.exs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
defmodule ErrorTracker.IgnorerTest do
22
use ErrorTracker.Test.Case
33

4-
setup_all do
5-
Application.put_env(:error_tracker, :ignorer, ErrorTracker.EveryErrorIgnorer)
4+
setup context do
5+
if ignorer = context[:ignorer] do
6+
previous_setting = Application.get_env(:error_tracker, :ignorer)
7+
Application.put_env(:error_tracker, :ignorer, ignorer)
8+
# Ensure that the application env is restored after each test
9+
on_exit(fn -> Application.put_env(:error_tracker, :ignorer, previous_setting) end)
10+
end
11+
12+
[]
613
end
714

8-
test "ignores errors" do
15+
@tag ignorer: ErrorTracker.EveryErrorIgnorer
16+
test "with an ignorer ignores errors" do
917
refute report_error(fn -> raise "[IGNORE] Sample error" end)
1018
assert report_error(fn -> raise "Sample error" end)
1119
end
20+
21+
@tag ignorer: false
22+
test "without an ignorer does not ignore errors" do
23+
assert report_error(fn -> raise "[IGNORE] Sample error" end)
24+
assert report_error(fn -> raise "Sample error" end)
25+
end
1226
end
1327

1428
defmodule ErrorTracker.EveryErrorIgnorer do

0 commit comments

Comments
 (0)