1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-18 15:41:17 +00:00

more logger tests

This commit is contained in:
Nikolay Kim 2017-11-23 15:37:11 -08:00
parent e571587a8c
commit 155a636487

View file

@ -293,7 +293,29 @@ mod tests {
use http::header::{self, HeaderMap};
#[test]
fn test_default_logger() {
fn test_logger() {
let logger = Logger::new("%% %{User-Agent}i %{X-Test}o %{HOME}e %D test");
let mut headers = HeaderMap::new();
headers.insert(header::USER_AGENT, header::HeaderValue::from_static("ACTIX-WEB"));
let mut req = HttpRequest::new(
Method::GET, "/".to_owned(), Version::HTTP_11, headers, String::new());
let resp = HttpResponse::builder(StatusCode::OK)
.header("X-Test", "ttt")
.force_close().body(Body::Empty).unwrap();
match logger.start(&mut req) {
Started::Done => (),
_ => panic!(),
}
match logger.finish(&mut req, &resp) {
Finished::Done => (),
_ => panic!(),
}
}
#[test]
fn test_default_format() {
let format = Format::default();
let mut headers = HeaderMap::new();
@ -316,7 +338,7 @@ mod tests {
assert!(s.contains("ACTIX-WEB"));
let req = HttpRequest::new(
Method::GET, "/?test".to_owned(), Version::HTTP_11, HeaderMap::new(), String::new());
Method::GET, "/".to_owned(), Version::HTTP_11, HeaderMap::new(), "test".to_owned());
let resp = HttpResponse::builder(StatusCode::OK)
.force_close().body(Body::Empty).unwrap();
let entry_time = time::now();