Skip to content

Commit 6e667d8

Browse files
committed
update tests
1 parent eeeab32 commit 6e667d8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/algora/payments_test.exs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule Algora.PaymentsTest do
1818
{:ok, user: user, account: account}
1919
end
2020

21-
test "executes transfer when there are pending credits", %{user: user, account: account} do
21+
test "executes transfer when user has positive balance", %{user: user, account: account} do
2222
insert(:transaction,
2323
user: user,
2424
type: :credit,
@@ -61,9 +61,20 @@ defmodule Algora.PaymentsTest do
6161
assert Money.equal?(transfer_tx.total_fee, Money.new(0, :USD))
6262
end
6363

64-
test "does nothing when user has no pending credits", %{user: user} do
64+
test "does nothing when user has positive unconfirmed balance", %{user: user} do
65+
insert(:transaction,
66+
user: user,
67+
type: :credit,
68+
status: :processing,
69+
net_amount: Money.new(1, :USD)
70+
)
71+
6572
assert {:ok, nil} = Payments.execute_pending_transfers(user.id)
73+
assert Transaction |> where([t], t.type == :transfer) |> Repo.aggregate(:count) == 0
74+
end
6675

76+
test "does nothing when user has zero balance", %{user: user} do
77+
assert {:ok, nil} = Payments.execute_pending_transfers(user.id)
6778
assert Repo.aggregate(Transaction, :count) == 0
6879
end
6980

0 commit comments

Comments
 (0)