-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mercadopago] authorization tests #142
Conversation
@@ -2,35 +2,136 @@ defmodule Gringotts.Integration.Gateways.MercadopagoTest do | |||
# Integration tests for the Mercadopago | |||
|
|||
use ExUnit.Case, async: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run tests asynchronously.
|
||
describe "environment setup" do | ||
test "old customer with bad_opts and bad_opts" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in title 😁
public_key: "TEST-911f45a1-0560-4c16-915e-a8833830b29a"], | ||
installments: 1 | ||
] | ||
@new_cutomer_bad_opts [order_id: 123126, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only difference between @new_cutomer_good_opts
and @new_cutomer_bad_opts
is in the :config
key. Please do not test the presence or absence of required_fields in your opts
because the tests for that have been written in gringotts_test.exs
@good_opts [email: "[email protected]", | ||
order_id: 123126, | ||
customer_id: "311211654-YrXF6J0QikpIWX", | ||
config: [access_token: "TEST-2774702803649645-031303-1b9d3d63acb57cdad3458d386eee62bd-307592510", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move the :config
key out and make it a module attribute.
end | ||
|
||
describe "refund" do | ||
end | ||
describe "[authorize]" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you break this describe block into two, authorize new customer
and authorize old customer
?
I'm sure you'll be able to use new_email_opts/1
as a setup
function (docs).
Codecov Report
@@ Coverage Diff @@
## mercadopago #142 +/- ##
===============================================
- Coverage 57.62% 50.19% -7.43%
===============================================
Files 15 15
Lines 472 504 +32
===============================================
- Hits 272 253 -19
- Misses 200 251 +51
Continue to review full report at Codecov.
|
85bf31f
to
8980821
Compare
templates/test.eex
Outdated
@@ -1,15 +1,13 @@ | |||
defmodule Gringotts.Gateways.<%= gateway_module <> "Test" %> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this file from this PR.
defmodule Gringotts.Integration.Gateways.MercadopagoTest do | ||
# Integration tests for the Mercadopago | ||
|
||
use ExUnit.Case, async: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async
true pls! We ❤️ fast tests.
|
||
test "new cutomer with good_opts and good_card" do | ||
use_cassette "mercadopago/authorize_new cutomer with good_opts and good_card" do | ||
opts = new_email_opts(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please read up on how to use a setup function in tests. This test and the one below it can be clubbed in a describe
block with a common setup function that generates "new email opts".
test/mocks/mercadopago_mock.exs
Outdated
@@ -0,0 +1,7 @@ | |||
defmodule Gringotts.Gateways.MercadopagoMock do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this file as well.
https://www.mercadopago.com/ * Implements `authorize/3`. * `@moduledoc` and docs added authorize --------- * Following optional arguments implemented: - `email`, `order_id`, `customer_id`, `order_type`, `installments` * Mercadopago provides an `access_token` and ` `public_key` for auth. * Mercadopago payments don't have any (writable) currency field, it seems that currency of the transaction is set by Mercadopago automatically from the merchant account.
bb70df3
to
15958f3
Compare
15958f3
to
800930c
Compare
800930c
to
bee7a4d
Compare
Superceded by #185 |
No description provided.