Add LastFm.Config test

It might seem redundant, but helps with refactoring down the line.
This commit is contained in:
Claudio Ortolina
2024-12-04 09:56:51 +00:00
parent 740e94fdf6
commit 0cae20a390
2 changed files with 21 additions and 3 deletions
+1 -3
View File
@@ -15,9 +15,7 @@ defmodule LastFm.Config do
@spec resolve(atom) :: t @spec resolve(atom) :: t
def resolve(otp_app) do def resolve(otp_app) do
app_config = app_config = Application.get_env(otp_app, LastFm)
otp_app
|> Application.get_env(LastFm)
struct(__MODULE__, app_config) struct(__MODULE__, app_config)
end end
+20
View File
@@ -0,0 +1,20 @@
defmodule LastFm.ConfigTest do
use ExUnit.Case, async: true
describe "resolve/1" do
test "reads data from application configuration" do
assert %LastFm.Config{
api: LastFm.APIBehaviourMock,
api_key: api_key,
user: user,
auto_refresh: false,
refresh_interval: refresh_interval
} =
LastFm.Config.resolve(:music_library)
assert is_binary(api_key)
assert is_binary(user)
assert is_integer(refresh_interval)
end
end
end