assert_copy has wrong name, but the idea is simple, it is equivalent to:
match_keys = Enum.sort(Map.keys(match))
original_keys = Enum.sort(Map.keys(original))
assert a_keys == b_keys
for key <- match_keys -- (Keyword.keys(except) ++ ignoring) do
assert Map.fetch!(match, key) == Map.fetch!(original, key)
end
for {key, value} <- except do
assert Map.fetch!(match, key) == value
end
In other words - it checks whether the match has the same structure and fields as origin ignoring ignoring fields and ensuring that except fields are matched exactly as is. This is useful for example when testing functions that return data from DB after updates, to check that only thing that has changed are the provided fields and no other field.
But yes, naming is poor.






















