Add unit tests to raise coverage score
Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
This commit is contained in:
committed by
Adrian Catangiu
parent
9e6ab4b5ab
commit
49240ce1d5
@@ -432,6 +432,7 @@ mod tests {
|
||||
assert_eq!(headers.content_length(), 0);
|
||||
assert_eq!(headers.chunked(), false);
|
||||
assert_eq!(headers.expect(), false);
|
||||
assert_eq!(headers.accept(), MediaType::PlainText);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -726,4 +727,13 @@ mod tests {
|
||||
let header = Header::try_from(b"Accept").unwrap();
|
||||
assert_eq!(header.raw(), b"Accept");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_accept() {
|
||||
let mut headers = Headers::default();
|
||||
assert_eq!(headers.accept(), MediaType::PlainText);
|
||||
|
||||
headers.set_accept(MediaType::ApplicationJson);
|
||||
assert_eq!(headers.accept(), MediaType::ApplicationJson);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,6 +522,14 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_display_route_error() {
|
||||
assert_eq!(
|
||||
format!("{}", RouteError::HandlerExist("test".to_string())),
|
||||
"handler for test already exists"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_method_to_str() {
|
||||
let val = Method::Get;
|
||||
|
||||
@@ -383,4 +383,15 @@ mod tests {
|
||||
response.allow_method(Method::Put);
|
||||
assert_eq!(response.allow(), vec![Method::Get, Method::Put]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_equal() {
|
||||
let response = Response::new(Version::Http10, StatusCode::MethodNotAllowed);
|
||||
let another_response = Response::new(Version::Http10, StatusCode::MethodNotAllowed);
|
||||
assert_eq!(response, another_response);
|
||||
|
||||
let response = Response::new(Version::Http10, StatusCode::OK);
|
||||
let another_response = Response::new(Version::Http10, StatusCode::BadRequest);
|
||||
assert_ne!(response, another_response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user