pub struct TestServer;
Expand description
The TestServer
type.
TestServer
is very simple test server that simplify process of writing
integration tests for actix-net applications.
§Examples
use actix_service::fn_service;
use actix_testing::TestServer;
#[actix_rt::main]
async fn main() {
let srv = TestServer::with(|| fn_service(
|sock| async move {
println!("New connection: {:?}", sock);
Ok::<_, ()>(())
}
));
println!("SOCKET: {:?}", srv.connect());
}
Implementations§
Source§impl TestServer
impl TestServer
Sourcepub fn start<F>(factory: F) -> TestServerRuntime
pub fn start<F>(factory: F) -> TestServerRuntime
Start new server with server builder
Sourcepub fn with<F: ServiceFactory<TcpStream>>(factory: F) -> TestServerRuntime
pub fn with<F: ServiceFactory<TcpStream>>(factory: F) -> TestServerRuntime
Start new test server with application factory
Sourcepub fn unused_addr() -> SocketAddr
pub fn unused_addr() -> SocketAddr
Get firat available unused local address
Auto Trait Implementations§
impl Freeze for TestServer
impl RefUnwindSafe for TestServer
impl Send for TestServer
impl Sync for TestServer
impl Unpin for TestServer
impl UnwindSafe for TestServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more