Skip to content

Commit 1581f1b

Browse files
committed
test: Added template info test
1 parent 53672f0 commit 1581f1b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_protocol_v7.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,33 @@ fn test_stacktrace() {
331331
);
332332
}
333333

334+
#[test]
335+
fn test_template_info() {
336+
let event = v7::Event {
337+
template_info: Some(v7::TemplateInfo {
338+
location: v7::FileLocation {
339+
filename: Some("hello.html".into()),
340+
line: Some(1),
341+
..Default::default()
342+
},
343+
source: v7::EmbeddedSources {
344+
pre_lines: vec!["foo1".into(), "bar2".into()],
345+
current_line: Some("hey hey hey3".into()),
346+
post_lines: vec!["foo4".into(), "bar5".into()],
347+
},
348+
}),
349+
..Default::default()
350+
};
351+
352+
assert_roundtrip(&event);
353+
assert_eq!(
354+
serde_json::to_string(&event).unwrap(),
355+
"{\"template\":{\"filename\":\"hello.html\",\"lineno\":1,\
356+
\"pre_context\":[\"foo1\",\"bar2\"],\"context_line\":\
357+
\"hey hey hey3\",\"post_context\":[\"foo4\",\"bar5\"]}}"
358+
);
359+
}
360+
334361
#[test]
335362
fn test_request() {
336363
let event = v7::Event {

0 commit comments

Comments
 (0)