Skip to content

Commit

Permalink
Fix tests on Elixir 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Sep 20, 2023
1 parent 43b7783 commit a4ee2ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule Sentry.ConfigTest do
test "raises if not set" do
assert_raise RuntimeError, ~r/:environment_name must be set/, fn ->
modify_env(:sentry, environment_name: nil)
modify_system_env(%{"SENTRY_ENVIRONMENT" => nil})
delete_system_env("SENTRY_ENVIRONMENT")
Config.environment_name()
end
end
Expand Down
13 changes: 13 additions & 0 deletions test/support/test_environment_helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,17 @@ defmodule Sentry.TestEnvironmentHelper do
end)
end)
end

def delete_system_env(variable) do
original_env = System.fetch_env(variable)

System.delete_env(variable)

ExUnit.Callbacks.on_exit(fn ->
case original_env do
{:ok, val} -> System.put_env(variable, val)
:error -> :ok
end
end)
end
end

0 comments on commit a4ee2ed

Please sign in to comment.