1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 09:42:57 +01:00

better logger format test

This commit is contained in:
Nikolay Kim 2017-11-23 16:53:02 -08:00
parent 39a20fb95d
commit 5529ea0428

View File

@ -286,7 +286,6 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
#[cfg(test)]
mod tests {
extern crate env_logger;
use Body;
use super::*;
use time;
@ -295,7 +294,6 @@ mod tests {
#[test]
fn test_logger() {
let _ = env_logger::init();
let logger = Logger::new("%% %{User-Agent}i %{X-Test}o %{HOME}e %D test");
let mut headers = HeaderMap::new();
@ -314,6 +312,15 @@ mod tests {
Finished::Done => (),
_ => panic!(),
}
let entry_time = time::now();
let render = |fmt: &mut Formatter| {
for unit in logger.format.0.iter() {
unit.render(fmt, &req, &resp, entry_time)?;
}
Ok(())
};
let s = format!("{}", FormatDisplay(&render));
assert!(s.contains("ACTIX-WEB ttt"));
}
#[test]