forked from aviabird/gringotts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mix task for tests, mocks and integration
Added mix task to generate test file for the gateways, add a file to define the mock responses and also to generate integration test.
- Loading branch information
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule Gringotts.Integration.Gateways.<%= gateway_module <> "Test"%> do | ||
# Integration tests for the <%= gateway_module%> | ||
|
||
use ExUnit.Case, async: false | ||
alias Gringotts.Gateways.<%= gateway_module%> | ||
|
||
@moduletag :integration | ||
|
||
setup_all do | ||
Application.put_env(:gringotts, Gringotts.Gateways.<%= gateway_module%>, | ||
[ | ||
adapter: Gringotts.Gateways.<%= gateway_module%><%= if required_config_keys != [] do %><%= for key <- Enum.intersperse(required_config_keys, ",") do %><%= if key === "," do %><%= "#{key}" %><%= else %> | ||
<%= "#{key}" %>: "your_secret_<%= "#{key}" %>"<% end %><% end %><% end %> | ||
] | ||
) | ||
end | ||
|
||
# Group the test cases by public api | ||
describe "purchase" do | ||
end | ||
|
||
describe "authorize" do | ||
end | ||
|
||
describe "capture" do | ||
end | ||
|
||
describe "void" do | ||
end | ||
|
||
describe "refund" do | ||
end | ||
|
||
describe "environment setup" do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule Gringotts.Gateways.<%= gateway_module <> "Mock"%> do | ||
|
||
# The module should include mock responses for test cases in <%= gateway_mock_test <> ".exs"%>. | ||
# e.g. | ||
# def successful_purchase do | ||
# {:ok, %HTTPoison.Response{body: ~s[{data: "successful_purchase"}]} | ||
# end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
defmodule Gringotts.Gateways.<%= gateway_module <> "Test" %> do | ||
# The file contains mocked tests for <%= gateway_module%> | ||
|
||
# We recommend using [mock][1] for this, you can place the mock responses from | ||
# the Gateway in `test/mocks/<%= gateway_mock_response%>.exs` file, which has also been | ||
# generated for you. | ||
# | ||
# [1]: https://github.com/jjh42/mock | ||
|
||
# Load the mock response file before running the tests. | ||
Code.require_file "../mocks/<%= gateway_mock_response <> ".exs"%>", __DIR__ | ||
|
||
use ExUnit.Case, async: false | ||
alias Gringotts.Gateways.<%= gateway_module%> | ||
import Mock | ||
|
||
# Group the test cases by public api | ||
describe "purchase" do | ||
end | ||
|
||
describe "authorize" do | ||
end | ||
|
||
describe "capture" do | ||
end | ||
|
||
describe "void" do | ||
end | ||
|
||
describe "refund" do | ||
end | ||
end |