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

Provide a way to instantiate ureq::Error::Transport for tests #373

Closed
tgeoghegan opened this issue Apr 20, 2021 · 3 comments
Closed

Provide a way to instantiate ureq::Error::Transport for tests #373

tgeoghegan opened this issue Apr 20, 2021 · 3 comments

Comments

@tgeoghegan
Copy link

tgeoghegan commented Apr 20, 2021

I have some retry logic that retries requests on certain HTTP status codes and on ureq::Error::Transport. I want to test my logic that determines if an error is retryable by feeding it synthetic ureq::Error values. I can easily create an instance of ureq::Error::Status since ureq::Response::new is public (as noted in the doccomment, it is indeed useful for unit tests), but there's no way for a client to create a ureq::Error::Transport value.

@algesten
Copy link
Owner

Can you make an std::io::Error and use convert that with .into()?

@tgeoghegan
Copy link
Author

tgeoghegan commented Apr 1, 2024

It looks like that would let me construct the Transport variant of ureq::Error, which I think might suffice for the testing case I described. I'm afraid I've since deleted the tests in question, so I don't really remember. So unless you have someone else asking for this, or some other motivation to do it, feel free to close without action.

@algesten
Copy link
Owner

algesten commented Apr 3, 2024

Thanks!

@algesten algesten closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants