Add the helpers for tests.

dev
KKlochko 3 months ago
parent 1a326cc8aa
commit 034882672a

@ -25,6 +25,7 @@ defmodule DecentralisedBookIndex.DataCase do
import Ecto.Query
import DecentralisedBookIndex.DataCase
import DecentralisedBookIndex.Generators
import DecentralisedBookIndex.Helpers
end
end

@ -0,0 +1,20 @@
defmodule DecentralisedBookIndex.Helpers do
@moduledoc "Helpers for tests"
@doc """
Rerurn a new map with same keys as in map_with_keys.
"""
def get_submap(map, map_with_keys) when is_map(map_with_keys) do
Map.take(map, Map.keys(map_with_keys))
end
def get_submap(map, keys) when is_list(keys) do
Map.take(map, keys)
end
def get_submaps(map_list, keys) do
Enum.map(map_list, fn map ->
get_submap(map, keys)
end)
end
end
Loading…
Cancel
Save