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

Function test_index

json/json/src/main.rs:63–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61
62 #[actix_web::test]
63 async fn test_index() {
64 let app =
65 test::init_service(App::new().service(web::resource("/").route(web::post().to(index))))
66 .await;
67
68 let req = test::TestRequest::post()
69 .uri("/")
70 .set_json(MyObj {
71 name: "my-name".to_owned(),
72 number: 43,
73 })
74 .to_request();
75 let resp = app.call(req).await.unwrap();
76
77 assert_eq!(resp.status(), http::StatusCode::OK);
78
79 let body_bytes = to_bytes(resp.into_body()).await.unwrap();
80 assert_eq!(body_bytes, r#"{"name":"my-name","number":43}"#);
81 }
82}

Callers

nothing calls this directly

Calls 2

postFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected