MCPcopy Create free account
hub / github.com/actix/examples / handle_post_3_unit_test

Function handle_post_3_unit_test

forms/form/src/main.rs:183–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182 #[actix_web::test]
183 async fn handle_post_3_unit_test() {
184 let req = TestRequest::default().to_http_request();
185 let params = Form(MyParams {
186 name: "John".to_owned(),
187 });
188 let result = handle_post_3(req.clone(), params).await;
189 let resp = result.respond_to(&req);
190 assert_eq!(resp.status(), StatusCode::OK);
191 assert_eq!(
192 resp.headers().get(CONTENT_TYPE).unwrap(),
193 HeaderValue::from_static("text/plain")
194 );
195 let body = match to_bytes(resp.into_body()).await {
196 Ok(x) => x,
197 _ => panic!(),
198 };
199 assert_eq!(body.as_str(), "Your name is John");
200 }
201
202 #[actix_web::test]
203 async fn handle_post_3_integration_test() {

Callers

nothing calls this directly

Calls 1

handle_post_3Function · 0.85

Tested by

no test coverage detected