basic_signup_allowlist/test/basic_signup_allowlist_test.exs
Your Name a89ed0c80c refactor: centralize SIGNUP_ALLOWLIST_EMAILS constant definition
Define environment variable name as a module attribute in BasicSignupAllowlist
and expose it via signup_allowlist_emails/0 function to eliminate duplication
across lib and test files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-16 09:40:11 +00:00

30 lines
866 B
Elixir

defmodule BasicSignupAllowlistTest do
use ExUnit.Case, async: false
doctest BasicSignupAllowlist
defp allow_signups_for(allowlist) do
System.put_env(BasicSignupAllowlist.signup_allowlist_emails(), allowlist)
end
describe "setup in describe block" do
setup do
on_exit(fn ->
# resetting values did not work, so 'just' set it to the effect without this module configured.
System.put_env(BasicSignupAllowlist.signup_allowlist_emails(), "*")
end)
:ok
end
test "When not set, not allowlisted" do
System.delete_env(BasicSignupAllowlist.signup_allowlist_emails())
refute BasicSignupAllowlist.mail_allowlisted("joe@example.com")
end
test "When set to star, allowlisted" do
allow_signups_for("*")
assert BasicSignupAllowlist.mail_allowlisted("joe@example.com")
end
end
end