From 1581f1ba7ba49bd39a8929d28847f284d94f3f70 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 25 Mar 2018 19:23:45 +0200 Subject: [PATCH] test: Added template info test --- tests/test_protocol_v7.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_protocol_v7.rs b/tests/test_protocol_v7.rs index bbb4b1e5..14baae32 100644 --- a/tests/test_protocol_v7.rs +++ b/tests/test_protocol_v7.rs @@ -331,6 +331,33 @@ fn test_stacktrace() { ); } +#[test] +fn test_template_info() { + let event = v7::Event { + template_info: Some(v7::TemplateInfo { + location: v7::FileLocation { + filename: Some("hello.html".into()), + line: Some(1), + ..Default::default() + }, + source: v7::EmbeddedSources { + pre_lines: vec!["foo1".into(), "bar2".into()], + current_line: Some("hey hey hey3".into()), + post_lines: vec!["foo4".into(), "bar5".into()], + }, + }), + ..Default::default() + }; + + assert_roundtrip(&event); + assert_eq!( + serde_json::to_string(&event).unwrap(), + "{\"template\":{\"filename\":\"hello.html\",\"lineno\":1,\ + \"pre_context\":[\"foo1\",\"bar2\"],\"context_line\":\ + \"hey hey hey3\",\"post_context\":[\"foo4\",\"bar5\"]}}" + ); +} + #[test] fn test_request() { let event = v7::Event {