View Source Doumi.Test.Comparison (Doumi.Test v0.2.0)
Summary
Functions
Compare two maps have the same value for a given fields. The two maps must always contain the given field.
Compare two records have the same primary keys.
Compare two values for equality.
Functions
Compare two maps have the same value for a given fields. The two maps must always contain the given field.
Examples
iex> Doumi.Test.Comparison.same_fields?(%{a: 1, b: 2}, %{a: 1, b: 2}, [:a, :b])
true
iex> Doumi.Test.Comparison.same_fields?(%{a: 1, b: 2}, %{a: 1, b: 3}, [:a, :b])
false
iex> Doumi.Test.Comparison.same_fields?(%{a: 1}, %{a: 1, b: 2}, [:a, :b])
** (KeyError) key :b not found in: %{a: 1}
@spec same_records?(Ecto.Schema.t(), Ecto.Schema.t()) :: boolean()
Compare two records have the same primary keys.
Compare two values for equality.
Examples
iex> Doumi.Test.Comparison.same_values?(1, 1)
true
iex> Doumi.Test.Comparison.same_values?("foo", "bar")
false
iex> Doumi.Test.Comparison.same_values?(~U[2023-01-01 00:00:00Z], ~U[2023-01-01 00:00:00.000Z])
true
iex> Doumi.Test.Comparison.same_values?(Decimal.new("1.1"), 1.1)
true