Skip to content

Commit

Permalink
cleanup test
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Rychlewski authored and Greg Rychlewski committed Jul 1, 2024
1 parent 5557326 commit acf6a62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
24 changes: 12 additions & 12 deletions test/query_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1760,18 +1760,18 @@ defmodule QueryTest do

assert [row1, row2] = query("SELECT * FROM timestamps", [])

assert [
%{microsecond: {_, 6}},
%{microsecond: {_, 3}},
%{microsecond: {_, 0}},
[%{microsecond: {_, 0}}, %{microsecond: {_, 0}}]
] = row1
assert [6, 3, 0, [0, 0]] =
Enum.map(row1, fn
[_ | _] = dts -> Enum.map(dts, &precision(&1))
dt -> precision(dt)
end)

assert [
%{microsecond: {_, 6}},
%{microsecond: {_, 3}},
%{microsecond: {_, 0}},
[%{microsecond: {_, 0}}, %{microsecond: {_, 0}}]
] = row2
assert [6, 3, 0, [0, 0]] =
Enum.map(row2, fn
[_ | _] = dts -> Enum.map(dts, &precision(&1))
dt -> precision(dt)
end)
end

defp precision(%NaiveDateTime{microsecond: {_, p}}), do: p
end
8 changes: 2 additions & 6 deletions test/transaction_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,7 @@ defmodule TransactionTest do
assert transaction(
fn conn ->
assert {:error, %Postgrex.Error{postgres: %{code: :unique_violation}}} =
P.query(conn, "insert into uniques values (1), (1);", [],
mode: :savepoint
)
P.query(conn, "insert into uniques values (1), (1);", [], mode: :savepoint)

assert {:ok, %Postgrex.Result{rows: [[42]]}} = P.query(conn, "SELECT 42", [])
:hi
Expand Down Expand Up @@ -595,9 +593,7 @@ defmodule TransactionTest do
assert transaction(
fn conn ->
assert {:error, %Postgrex.Error{postgres: %{code: :unique_violation}}} =
P.query(conn, "insert into uniques values (1), (1);", [],
mode: :savepoint
)
P.query(conn, "insert into uniques values (1), (1);", [], mode: :savepoint)

assert {:ok, %Postgrex.Result{rows: [[42]]}} = P.query(conn, "SELECT 42", [])
:hi
Expand Down

0 comments on commit acf6a62

Please sign in to comment.