diff options
author | Lindolfo 'Lorn' Rodrigues <lorn@lornlab.org> | 2020-03-17 19:30:34 -0300 |
---|---|---|
committer | Lindolfo 'Lorn' Rodrigues <lorn@lornlab.org> | 2020-03-19 23:29:50 -0300 |
commit | 6589586f985b466194a6553c50ab3f7419a13b7f (patch) | |
tree | cdb94939b65877c420abd60a26f3eab595b9aae6 /test | |
parent | Merge pull request #14 from locaweb/fix-docs (diff) |
Timeout option
Now, you need to pass the timeout for the PowerDNS API in seconds
We need to add the timeout to the GenServer.call function
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/powerdnsex/config_test.exs | 19 | ||||
-rw-r--r-- | test/support/fake_config.exs | 4 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/lib/powerdnsex/config_test.exs b/test/lib/powerdnsex/config_test.exs index eca2e03..37f0f63 100644 --- a/test/lib/powerdnsex/config_test.exs +++ b/test/lib/powerdnsex/config_test.exs @@ -5,6 +5,7 @@ defmodule PowerDNSex.ConfigTest do setup do: Config.set_url() setup do: Config.set_token() + setup do: Config.set_timeout() setup do: Config.set_url() && Config.set_token() describe "Config.powerdns_token/0" do @@ -56,4 +57,22 @@ defmodule PowerDNSex.ConfigTest do end end end + + describe "Config.powerdns_timeout/0" do + @tag :configs + test "using application config" do + assert PowerDNSex.Config.powerdns_timeout() == :timer.seconds(Config.timeout()) + end + + @tag :configs + test "given none timeout config" do + Application.delete_env(:powerdnsex, :timeout) + expected_error = "[PowerDNSex] PowerDNS timeout not configured." + + assert_raise RuntimeError, expected_error, fn -> + PowerDNSex.Config.powerdns_timeout() + end + end + end + end diff --git a/test/support/fake_config.exs b/test/support/fake_config.exs index c8f4f60..e05db22 100644 --- a/test/support/fake_config.exs +++ b/test/support/fake_config.exs @@ -1,10 +1,14 @@ defmodule PowerDNSex.FakeConfig do @app_config_token "S3cr37_70k3n" @app_config_url "https://my-powerdns.api" + @app_config_timeout 42 def set_url, do: Application.put_env(:powerdnsex, :url, @app_config_url) def set_token, do: Application.put_env(:powerdnsex, :token, @app_config_token) + def set_timeout, do: Application.put_env(:powerdnsex, :timeout, @app_config_timeout) + def token, do: @app_config_token def url, do: @app_config_url + def timeout, do: @app_config_timeout end |