mirror of
https://github.com/actix/actix-web.git
synced 2024-11-20 08:31:09 +00:00
better logger format test
This commit is contained in:
parent
39a20fb95d
commit
5529ea0428
1 changed files with 9 additions and 2 deletions
|
@ -286,7 +286,6 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate env_logger;
|
|
||||||
use Body;
|
use Body;
|
||||||
use super::*;
|
use super::*;
|
||||||
use time;
|
use time;
|
||||||
|
@ -295,7 +294,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_logger() {
|
fn test_logger() {
|
||||||
let _ = env_logger::init();
|
|
||||||
let logger = Logger::new("%% %{User-Agent}i %{X-Test}o %{HOME}e %D test");
|
let logger = Logger::new("%% %{User-Agent}i %{X-Test}o %{HOME}e %D test");
|
||||||
|
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
|
@ -314,6 +312,15 @@ mod tests {
|
||||||
Finished::Done => (),
|
Finished::Done => (),
|
||||||
_ => panic!(),
|
_ => 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]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue