Skip to content

Commit 4ffadd2

Browse files
committed
capture expected error logs in tests
1 parent 1de35ce commit 4ffadd2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

test/algora/payments_test.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
defmodule Algora.PaymentsTest do
22
use Algora.DataCase
33

4+
import ExUnit.CaptureLog
5+
46
alias Algora.Payments
57
alias Algora.Payments.Account
68
alias Algora.Payments.Transaction
@@ -99,7 +101,8 @@ defmodule Algora.PaymentsTest do
99101

100102
Account |> Repo.one!() |> change(%{provider_id: "acct_invalid"}) |> Repo.update!()
101103

102-
assert {:error, _} = Payments.execute_pending_transfers(user.id)
104+
{result, _log} = with_log(fn -> Payments.execute_pending_transfers(user.id) end)
105+
assert {:error, %Stripe.Error{code: :invalid_request_error}} = result
103106

104107
transfer_tx = Repo.one(from t in Transaction, where: t.type == :transfer)
105108
assert transfer_tx.status == :failed

test/algora_web/controllers/webhooks/github_controller_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
55

66
import Algora.Factory
77
import Ecto.Query
8+
import ExUnit.CaptureLog
89
import Money.Sigil
910

1011
alias Algora.Bounties.Bounty
@@ -33,7 +34,8 @@ defmodule AlgoraWeb.Webhooks.GithubControllerTest do
3334
describe "create bounties" do
3435
test "handles bounty command with unauthorized user", ctx do
3536
scenario = [%{event_action: "issue_comment.created", user_type: :unauthorized, body: "/bounty $100"}]
36-
assert {:error, :unauthorized} = process_scenario(ctx, scenario)
37+
{result, _log} = with_log(fn -> process_scenario(ctx, scenario) end)
38+
assert {:error, :unauthorized} = result
3739
assert Repo.aggregate(Bounty, :count) == 0
3840
end
3941

0 commit comments

Comments
 (0)