-
Notifications
You must be signed in to change notification settings - Fork 0
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
RFC for testing package design #1
Comments
How would this work if you were calling the Stripe modules from outside your actually test cases? Would you need to put something like this in your code?: if Mix.env == :test do
Stripe.Test.Customer.create(args)
else
Stripe.Customer.create(args)
end Maybe this could be done more simply through some configuration option? |
Nevermind 😄 I like the approach used in # config.exs
config :my_app,
stripe_api: Stripe
# config.test.exs
config :my_app,
stripe_api: Stripe.Test
# my_service.ex
@stripe Application.get_env(:my_app, :stripe_api)
...
def charge do
@stripe.Charges.create(...)
end |
Can we use a |
@johannesE thanks for the suggestion! Apologies if I'm being dense, but how exactly would |
I thought I provided an updated spec from this one that used GenServer instead of ETS due to the ETS table limit. In regards to This testing library is for integration tests, not unit tests. Due to the way that the Stripe API is designed, integration tests can't be performed easily against the live service; furthermore, it's not possible for people to perform them without a Stripe API key and is difficult to perform during CI tests. So while you can't get a full integration test using it, it provides a near alternative. |
I believe Stripe's OpenAPI spec can be used to generate a realistic mock. See beam-community/stripity-stripe#227. |
We should discuss what this should look like.
Here are some notes from beam-community/stripity-stripe#124
The test package can distribute a lightweight replica of the Stripe service. That way, testing can be done something like the following:
The data can be stored on a per-test basis in ETS, allowing users to build up the necessary state and tear it down without needing to know the intricacies of the system.
For example:
The text was updated successfully, but these errors were encountered: