Skip to content
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

Extract sync/async interfaces from Stripe services #1260

Closed
SeanFarrow opened this issue Aug 24, 2018 · 12 comments · Fixed by #1293
Closed

Extract sync/async interfaces from Stripe services #1260

SeanFarrow opened this issue Aug 24, 2018 · 12 comments · Fixed by #1293
Labels

Comments

@SeanFarrow
Copy link

It would be nice if we could use stripe services in unit tests. I'm happy using stripe-mock in integration tests, but the way things are currently mean I'll have to abstract the stripe services if I want to unit test them.

In the project I'm working on it is mandatory that we test as much as is possible.

@remi-stripe
Copy link
Contributor

@SeanFarrow You can write unit tests using the real API instead of stripe-mock without issues. This is not something we have blocked you from doing today and using the normal methods would let you hit the API as expected.

I'm likely misunderstanding what is blocking you though. If that's the case, could you provide some examples of what does not work for you?

@SeanFarrow
Copy link
Author

SeanFarrow commented Aug 24, 2018 via email

@remi-stripe
Copy link
Contributor

@SeanFarrow Okay I see what you mean now. I do see how it could be useful but I don't think it's something we'd ship in the near future. It's not something we have in any of the other libraries either today. I'll flag it as Future though in case it's something we could tackle in the future.

@SeanFarrow
Copy link
Author

SeanFarrow commented Aug 25, 2018 via email

@remi-stripe
Copy link
Contributor

@SeanFarrow We're in the middle of a pretty big refactor of the entire library so it might be worth waiting a few weeks. You can follow along in #1253 and #1252

We would definitely be interested in a PR though! What I'd recommend is to make a simple proof of concept on one service (or even one method) to showcase what you're aiming for and make sure it's the right direction. That way you don't do all the work for nothing

Let me know what you think!

@SeanFarrow
Copy link
Author

@remi-stripe,

That timescale works for me as I don't need this straight away.

I'll create interfaces from a single service as a proof of concept, do you have any suggestions as to what the best one would be?

@remi-stripe
Copy link
Contributor

@sean-stripe I'd use one of the most common ones like Customer or Charge!

@SeanFarrow
Copy link
Author

SeanFarrow commented Aug 26, 2018 via email

@remi-stripe
Copy link
Contributor

Those properties are definitely still in use! You set them to true to enable expansion of a connected resource. We have some custom code in the service logic that looks for properties that start with Expand and then do the right thing.

@nothrow
Copy link

nothrow commented Sep 3, 2018

Why do you need interfaces? All of the services' methods are virtual, and I'm mocking them in my unit tests with Moq successfully.

Also, for integration tests, I override StripeConfiguration.HttpMessageHandler with my read-response-from-assembly-resources custom handler.

@SeanFarrow
Copy link
Author

SeanFarrow commented Sep 4, 2018 via email

@ob-stripe
Copy link
Contributor

Implemented in 20.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants