fix: test invalid_segment_error()
@@ -49,18 +49,16 @@ async fn wildcard() {
assert_eq!(body.as_bytes(), b"-6");
}
-// #[test]
-// fn invalid_segment_error() {
-// let mut app = tide::Server::new();
-// app.at("/add_one/:num").get(add_one);
-// let mut server = make_server(app.into_http_service()).unwrap();
+#[async_std::test]
+async fn invalid_segment_error() {
+ let mut app = tide::new();
+ app.at("/add_one/:num").get(add_one);
-// let req = http::Request::get("/add_one/a")
-// .body(Body::empty())
-// .unwrap();
-// let res = server.simulate(req).unwrap();
-// assert_eq!(res.status(), 400);
-// }
+ let mut req = http::Request::new(Method::Get, "http://localhost/add_one/a".parse().unwrap());
+ req.set_body(Body::empty());
+ let res: http::Response = app.respond(req).await.unwrap();
+ assert_eq!(res.status(), StatusCode::BadRequest);
+}
// #[test]
// fn not_found_error() {
