How to create reqwest:Error
for mock
#1606
-
Hi, I'd like to create a mock for my unit tests that returns a Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thanks, appreciate the quick answer!
…On Wed, 17 Aug 2022 at 23:22, Sean McArthur ***@***.***> wrote:
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 🙈
—
Reply to this email directly, view it on GitHub
<#1606 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABL7KVROMIGLVB6N2PKTXGTVZVJXTANCNFSM5626W7WQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
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 toreqwest::Response
, and then callingerror_for_status()
. But I don't endorse this, nor promise it won't randomly break at some point 🙈