temporarily add no_run to middleware doctests (#626)

These test were failing because they made live requests to httpbin.org,
which is serving intermittent 500s.

In general we strive to make our test and doctests interact with a local
test server rather than a live website. For doctests we do this with
some sleight of hand in a hidden `ureq::is_test(true)`, which swaps out
the default agent returned by ureq::agent. However, since the middleware
doctests rely on constructing a custom agent with the middleware, they
can't rely on this.

I suspect we can get around this problem but it may take some thinking.

Similarly disable the AgentBuilder::user_agent and redirects doctests
and the agent_set_header unittest.
This commit is contained in:
Jacob Hoffman-Andrews
2023-06-13 23:00:26 -07:00
committed by GitHub
parent fbae1391ac
commit 905bf8f0b2
3 changed files with 27 additions and 26 deletions

View File

@@ -498,7 +498,7 @@ impl AgentBuilder {
/// WARNING: for 307 and 308 redirects, this value is ignored for methods that have a body.
/// You must handle 307 redirects yourself when sending a PUT, POST, PATCH, or DELETE request.
///
/// ```
/// ```no_run
/// # fn main() -> Result<(), ureq::Error> {
/// # ureq::is_test(true);
/// let result = ureq::builder()
@@ -535,7 +535,7 @@ impl AgentBuilder {
/// Defaults to `ureq/[VERSION]`. You can override the user-agent on an individual request by
/// setting the `User-Agent` header when constructing the request.
///
/// ```
/// ```no_run
/// # #[cfg(feature = "json")]
/// # fn main() -> Result<(), ureq::Error> {
/// # ureq::is_test(true);

View File

@@ -24,7 +24,7 @@ use crate::{Error, Request, Response};
///
/// A common use case is to add headers to the outgoing request. Here an example of how.
///
/// ```
/// ```no_run
/// # #[cfg(feature = "json")]
/// # fn main() -> Result<(), ureq::Error> {
/// # use ureq::{Request, Response, MiddlewareNext, Error};
@@ -58,7 +58,7 @@ use crate::{Error, Request, Response};
/// In the `examples` directory there is an additional example `count-bytes.rs` which uses
/// a mutex lock like shown below.
///
/// ```
/// ```no_run
/// # use ureq::{Request, Response, Middleware, MiddlewareNext, Error};
/// # use std::sync::{Arc, Mutex};
/// struct MyState {
@@ -89,7 +89,7 @@ use crate::{Error, Request, Response};
/// This example shows how we can increase a counter for each request going
/// through the agent.
///
/// ```
/// ```no_run
/// # fn main() -> Result<(), ureq::Error> {
/// # ureq::is_test(true);
/// use ureq::{Request, Response, Middleware, MiddlewareNext, Error};