mirror of
https://github.com/zerotier/ratpack.git
synced 2026-05-22 16:27:23 -07:00
Move tested methods inside tests; cleans a few things up
Signed-off-by: Erik Hollensbe <linux@hollensbe.org>
This commit is contained in:
+45
-40
@@ -80,47 +80,31 @@ impl Router {
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use http::{Request, Response};
|
||||
use hyper::Body;
|
||||
|
||||
use crate::{handler::Params, HTTPResult};
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn handler_static(
|
||||
req: Request<Body>,
|
||||
_response: Option<Response<Body>>,
|
||||
_params: Params,
|
||||
) -> HTTPResult {
|
||||
return Ok((
|
||||
req,
|
||||
Some(
|
||||
Response::builder()
|
||||
.status(400)
|
||||
.body(Body::from("hello, world".as_bytes()))?,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn handler_dynamic(
|
||||
req: Request<Body>,
|
||||
_response: Option<Response<Body>>,
|
||||
params: Params,
|
||||
) -> HTTPResult {
|
||||
return Ok((
|
||||
req,
|
||||
Some(Response::builder().status(400).body(Body::from(format!(
|
||||
"hello, {}",
|
||||
*params.get("name").unwrap()
|
||||
)))?),
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_route_dynamic() {
|
||||
use http::{Method, Request, Response};
|
||||
use hyper::Body;
|
||||
|
||||
use crate::{
|
||||
handler::{Handler, Params},
|
||||
HTTPResult,
|
||||
};
|
||||
|
||||
use super::Route;
|
||||
use crate::handler::Handler;
|
||||
use http::Method;
|
||||
|
||||
async fn handler_dynamic(
|
||||
req: Request<Body>,
|
||||
_response: Option<Response<Body>>,
|
||||
params: Params,
|
||||
) -> HTTPResult {
|
||||
return Ok((
|
||||
req,
|
||||
Some(Response::builder().status(400).body(Body::from(format!(
|
||||
"hello, {}",
|
||||
*params.get("name").unwrap()
|
||||
)))?),
|
||||
));
|
||||
}
|
||||
|
||||
let route = Route::new(
|
||||
Method::GET,
|
||||
@@ -184,9 +168,30 @@ mod tests {
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_route_static() {
|
||||
use http::{Method, Request, Response};
|
||||
use hyper::Body;
|
||||
|
||||
use crate::{
|
||||
handler::{Handler, Params},
|
||||
HTTPResult,
|
||||
};
|
||||
|
||||
use super::Route;
|
||||
use crate::handler::Handler;
|
||||
use http::Method;
|
||||
|
||||
async fn handler_static(
|
||||
req: Request<Body>,
|
||||
_response: Option<Response<Body>>,
|
||||
_params: Params,
|
||||
) -> HTTPResult {
|
||||
return Ok((
|
||||
req,
|
||||
Some(
|
||||
Response::builder()
|
||||
.status(400)
|
||||
.body(Body::from("hello, world".as_bytes()))?,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
let route = Route::new(
|
||||
Method::GET,
|
||||
|
||||
Reference in New Issue
Block a user