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

"Request" local files #47

Open
waiting-for-dev opened this issue Jul 30, 2018 · 7 comments
Open

"Request" local files #47

waiting-for-dev opened this issue Jul 30, 2018 · 7 comments

Comments

@waiting-for-dev
Copy link
Contributor

Hi there. First of all, thanks for this great work.

I'm currently developing an application which needs to request some user provided URLs. My issue is related with testing it.

Testing has a lot to do with trusting, and I trust that req works fine because it has its own test suite and it is being used by the community. For this reason, I don't like and I don't see the reason why my tests should be non-deterministic because of the need to reach external end-points which could be not available at some point.

For my own confidence, it would be enough to be able to provide in my test suite a location for a local file which content would act as a response body.

Of course, I see some inconvenient with this. Maybe it is pushing the abstraction out of its scope, because, which method should that request have and which headers should the response have?

Maybe another module Nework.HTTP.Req.Testing could be added implementing the needed logic, but surely some changes in the core system would be necessary. Maybe adding another Scheme constructor called Local, or maybe to make req function not depend on Url but on something implementing a new Url type class.

How do you see it? Am I missing a better approach?

Thanks

@waiting-for-dev
Copy link
Contributor Author

I think I found the solution.

@mrkkrp
Copy link
Owner

mrkkrp commented Jul 31, 2018

Note that the current version of the library works a bit differently. You still should be able to use req', see how pure-tests is written.

@waiting-for-dev
Copy link
Contributor Author

I see. The problem is that what I'm testing is a function that internally uses req and not req'. You can think of this function as a function taking an URL as parameter, performing the request with req and returning a handcrafted version of the response within an IO.

So I think I come back to my first thought... Considering the option to support the file scheme in req.

@mrkkrp
Copy link
Owner

mrkkrp commented Aug 1, 2018

Does http-client support file scheme?

@waiting-for-dev
Copy link
Contributor Author

No, as far as I know, it doesn't 😞

@mrkkrp
Copy link
Owner

mrkkrp commented Aug 3, 2018

The most logical way to add this is to add the feature to http-client and then add a new scheme to Req (Req is built on top of http-client).

@waiting-for-dev
Copy link
Contributor Author

I agree this should be the way to go. I submitted an issue there.

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

No branches or pull requests

2 participants