#![cfg(not(feature = "openapi"))] use rweb::{get, Filter, Rejection}; async fn task() -> Result { Ok(String::from("TEST")) } #[get("/")] async fn index() -> Result { task().await } #[tokio::test] async fn index_test() { let value = warp::test::request() .path("/") .reply(&index()) .await .into_body(); assert_eq!(value, b"TEST"[..]); } #[get("/foo")] async fn foo() -> Result { task().await } #[tokio::test] async fn foo_test() { let filter = assert_filter(foo()); let value = warp::test::request() .path("/foo") .reply(&filter) .await .into_body(); assert_eq!(value, b"TEST"[..]); } #[get("/param/{foo}")] async fn param(foo: String) -> Result { println!("{}", foo); // to use it task().await } #[tokio::test] async fn param_test() { let filter = assert_filter(param()); let value = warp::test::request() .path("/param/param") .reply(&filter) .await .into_body(); assert_eq!(value, b"TEST"[..]); } fn assert_filter( f: F, ) -> impl Filter where F: Filter, { f }