Skip to content

How to create reqwest:Error for mock #1606

Answered by seanmonstar
agostbiro asked this question in Q&A
Discussion options

You must be logged in to vote

Officially, there is no way to do this. I usually recommend finding other patterns than mocking when doing unit tests.


That said, I suppose you could get one in a roundabout way, by creating an http::Response, converting that to reqwest::Response, and then calling error_for_status(). But I don't endorse this, nor promise it won't randomly break at some point 🙈

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by agostbiro
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants