Add unit tests to raise coverage score

Signed-off-by: YUAN LYU <lyuyuan92@gmail.com>
This commit is contained in:
YUAN LYU
2021-04-02 15:29:21 -04:00
committed by Adrian Catangiu
parent 9e6ab4b5ab
commit 49240ce1d5
4 changed files with 30 additions and 1 deletions

View File

@@ -1 +1 @@
{"coverage_score": 92.5, "exclude_path": "", "crate_features": ""}
{"coverage_score": 93.1, "exclude_path": "", "crate_features": ""}

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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);
}
}