Struct actix_test::TestServer
source · pub struct TestServer { /* private fields */ }
Expand description
A basic HTTP server controller that simplifies the process of writing integration tests for Actix Web applications.
See start
for usage example.
Implementations§
source§impl TestServer
impl TestServer
sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Construct test server url
sourcepub fn get(&self, path: impl AsRef<str>) -> ClientRequest
pub fn get(&self, path: impl AsRef<str>) -> ClientRequest
Create GET
request.
sourcepub fn post(&self, path: impl AsRef<str>) -> ClientRequest
pub fn post(&self, path: impl AsRef<str>) -> ClientRequest
Create POST
request.
sourcepub fn head(&self, path: impl AsRef<str>) -> ClientRequest
pub fn head(&self, path: impl AsRef<str>) -> ClientRequest
Create HEAD
request.
sourcepub fn put(&self, path: impl AsRef<str>) -> ClientRequest
pub fn put(&self, path: impl AsRef<str>) -> ClientRequest
Create PUT
request.
sourcepub fn patch(&self, path: impl AsRef<str>) -> ClientRequest
pub fn patch(&self, path: impl AsRef<str>) -> ClientRequest
Create PATCH
request.
sourcepub fn delete(&self, path: impl AsRef<str>) -> ClientRequest
pub fn delete(&self, path: impl AsRef<str>) -> ClientRequest
Create DELETE
request.
sourcepub fn options(&self, path: impl AsRef<str>) -> ClientRequest
pub fn options(&self, path: impl AsRef<str>) -> ClientRequest
Create OPTIONS
request.
sourcepub fn request(&self, method: Method, path: impl AsRef<str>) -> ClientRequest
pub fn request(&self, method: Method, path: impl AsRef<str>) -> ClientRequest
Connect request with given method and path.
pub async fn load_body<S>( &mut self, response: ClientResponse<S> ) -> Result<Bytes, PayloadError>
sourcepub async fn ws_at(
&mut self,
path: &str
) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>
pub async fn ws_at( &mut self, path: &str ) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>
Connect to WebSocket server at a given path.
sourcepub async fn ws(
&mut self
) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>
pub async fn ws( &mut self ) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>
Connect to a WebSocket server.
sourcepub fn client_headers(&mut self) -> Option<&mut HeaderMap>
pub fn client_headers(&mut self) -> Option<&mut HeaderMap>
Get default HeaderMap of Client.
Returns Some(&mut HeaderMap) when Client object is unique (No other clone of client exists at the same time).
Trait Implementations§
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