mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 07:48:39 +01:00
cfg UnixListener tests for unix (#3085)
This commit is contained in:
parent
9cd5cc4fc1
commit
8af2f27877
1 changed files with 19 additions and 3 deletions
|
@ -415,15 +415,20 @@ mod tests {
|
|||
use axum_core::{body::Body, extract::Request};
|
||||
use http::StatusCode;
|
||||
use hyper_util::rt::TokioIo;
|
||||
#[cfg(unix)]
|
||||
use tokio::net::UnixListener;
|
||||
use tokio::{
|
||||
io::{self, AsyncRead, AsyncWrite},
|
||||
net::{TcpListener, UnixListener},
|
||||
net::TcpListener,
|
||||
};
|
||||
|
||||
use super::{serve, IncomingStream, Listener};
|
||||
#[cfg(unix)]
|
||||
use super::IncomingStream;
|
||||
use super::{serve, Listener};
|
||||
#[cfg(unix)]
|
||||
use crate::extract::connect_info::Connected;
|
||||
use crate::{
|
||||
body::to_bytes,
|
||||
extract::connect_info::Connected,
|
||||
handler::{Handler, HandlerWithoutStateExt},
|
||||
routing::get,
|
||||
serve::ListenerExt,
|
||||
|
@ -435,6 +440,7 @@ mod tests {
|
|||
#[derive(Clone, Debug)]
|
||||
struct UdsConnectInfo;
|
||||
|
||||
#[cfg(unix)]
|
||||
impl Connected<IncomingStream<'_, UnixListener>> for UdsConnectInfo {
|
||||
fn connect_info(_stream: IncomingStream<'_, UnixListener>) -> Self {
|
||||
Self
|
||||
|
@ -458,6 +464,7 @@ mod tests {
|
|||
serve(tcp_nodelay_listener().await, router.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
#[cfg(unix)]
|
||||
serve(UnixListener::bind("").unwrap(), router.clone());
|
||||
|
||||
serve(
|
||||
|
@ -468,6 +475,7 @@ mod tests {
|
|||
tcp_nodelay_listener().await,
|
||||
router.clone().into_make_service(),
|
||||
);
|
||||
#[cfg(unix)]
|
||||
serve(
|
||||
UnixListener::bind("").unwrap(),
|
||||
router.clone().into_make_service(),
|
||||
|
@ -485,6 +493,7 @@ mod tests {
|
|||
.clone()
|
||||
.into_make_service_with_connect_info::<std::net::SocketAddr>(),
|
||||
);
|
||||
#[cfg(unix)]
|
||||
serve(
|
||||
UnixListener::bind("").unwrap(),
|
||||
router.into_make_service_with_connect_info::<UdsConnectInfo>(),
|
||||
|
@ -493,6 +502,7 @@ mod tests {
|
|||
// method router
|
||||
serve(TcpListener::bind(addr).await.unwrap(), get(handler));
|
||||
serve(tcp_nodelay_listener().await, get(handler));
|
||||
#[cfg(unix)]
|
||||
serve(UnixListener::bind("").unwrap(), get(handler));
|
||||
|
||||
serve(
|
||||
|
@ -503,6 +513,7 @@ mod tests {
|
|||
tcp_nodelay_listener().await,
|
||||
get(handler).into_make_service(),
|
||||
);
|
||||
#[cfg(unix)]
|
||||
serve(
|
||||
UnixListener::bind("").unwrap(),
|
||||
get(handler).into_make_service(),
|
||||
|
@ -516,6 +527,7 @@ mod tests {
|
|||
tcp_nodelay_listener().await,
|
||||
get(handler).into_make_service_with_connect_info::<std::net::SocketAddr>(),
|
||||
);
|
||||
#[cfg(unix)]
|
||||
serve(
|
||||
UnixListener::bind("").unwrap(),
|
||||
get(handler).into_make_service_with_connect_info::<UdsConnectInfo>(),
|
||||
|
@ -527,6 +539,7 @@ mod tests {
|
|||
handler.into_service(),
|
||||
);
|
||||
serve(tcp_nodelay_listener().await, handler.into_service());
|
||||
#[cfg(unix)]
|
||||
serve(UnixListener::bind("").unwrap(), handler.into_service());
|
||||
|
||||
serve(
|
||||
|
@ -534,6 +547,7 @@ mod tests {
|
|||
handler.with_state(()),
|
||||
);
|
||||
serve(tcp_nodelay_listener().await, handler.with_state(()));
|
||||
#[cfg(unix)]
|
||||
serve(UnixListener::bind("").unwrap(), handler.with_state(()));
|
||||
|
||||
serve(
|
||||
|
@ -541,6 +555,7 @@ mod tests {
|
|||
handler.into_make_service(),
|
||||
);
|
||||
serve(tcp_nodelay_listener().await, handler.into_make_service());
|
||||
#[cfg(unix)]
|
||||
serve(UnixListener::bind("").unwrap(), handler.into_make_service());
|
||||
|
||||
serve(
|
||||
|
@ -551,6 +566,7 @@ mod tests {
|
|||
tcp_nodelay_listener().await,
|
||||
handler.into_make_service_with_connect_info::<std::net::SocketAddr>(),
|
||||
);
|
||||
#[cfg(unix)]
|
||||
serve(
|
||||
UnixListener::bind("").unwrap(),
|
||||
handler.into_make_service_with_connect_info::<UdsConnectInfo>(),
|
||||
|
|
Loading…
Reference in a new issue