pub async fn get<'a, SERVICE, BODY, E>(
app: &'a mut SERVICE,
url: &'a str,
) -> Result<RespBody>where
BODY: MessageBody + Unpin,
E: Debug,
SERVICE: Service<Request = Request, Response = ServiceResponse<BODY>, Error = E>,Expand description
Get test method for Actix server
use actix_web::{dev::ServiceResponse, web, Responder, test};
use actix_service::Service;
async fn index(info: web::Path<(u32, String)>) -> impl Responder {
let (id, name) = info.into_inner();
format!("Hello {}! id:{}", name, id)
}
#[actix_rt::test]
async fn test_minimal() {
let mut app = test::init_service(App::new().service(index)).await;
let resp = get(&mut app, "/32/Filip").await;
assert_eq!(resp.status.as_u16(), 200);
assert_eq!(resp.body, "Hello Filip! id:32");
}