Packages
charon
2.2.0
4.3.0
4.3.0-beta1
4.2.0
4.2.0-beta3
4.2.0-beta2
4.2.0-beta1
4.1.0
4.0.1
4.0.0
4.0.0-beta3
4.0.0-beta2
4.0.0-beta1
3.4.1
3.4.0
3.3.0
3.2.0
3.1.1
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-beta1
2.8.0
2.8.0-beta1
2.7.3
2.7.2
2.7.1
2.7.0
2.6.1
2.6.0
2.5.0
2.4.0
2.3.0
2.2.0
2.2.0-beta
2.1.3
2.1.2
2.1.2-beta
2.1.1
2.1.0
2.0.0
1.3.4
1.3.3
1.3.2-beta
1.3.1-beta
1.3.0-beta
1.2.0-beta
1.1.0-beta
1.0.1-beta
1.0.0-beta1
0.0.4-alpha
0.0.3-alpha
0.0.2-alpha
0.0.1-alpha
Authentication & sessions for API's.
Current section
Files
Jump to
Current section
Files
lib/charon/internal/config_test.ex
defmodule Charon.Internal.ConfigTest do
@moduledoc false
import ExUnit.Assertions
defp required_keys(config) do
config |> Enum.filter(&match?({_k, :required}, &1)) |> Enum.map(fn {k, _} -> k end)
end
defp optional_keys(required_keys, config) do
config |> Map.keys() |> Kernel.--(required_keys)
end
def test_optional(configurations) do
for {mod, config} <- configurations do
optional = config |> required_keys() |> optional_keys(config)
for opt <- optional do
val = config |> Map.delete(opt) |> mod.from_enum() |> Map.get(opt)
default = config[opt]
assert val == default,
"expected #{inspect(default)} default value for :#{opt} of #{mod}"
end
end
end
def test_required(configurations) do
for {mod, config} <- configurations do
required = config |> required_keys()
for req <- required do
assert_raise ArgumentError, fn ->
config |> Map.delete(req) |> mod.from_enum()
end
end
end
end
end