From 842be0a664af31a2161cb65cc3e1870663dc3c38 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 24 Mar 2018 00:13:16 +0100 Subject: [PATCH] test: Added request test --- tests/test_protocol_v7.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_protocol_v7.rs b/tests/test_protocol_v7.rs index b2d27769..fcd5b0d8 100644 --- a/tests/test_protocol_v7.rs +++ b/tests/test_protocol_v7.rs @@ -255,6 +255,41 @@ fn test_request() { {\"Content-Type\":\"text/plain\"},\"env\":\ {\"PATH_INFO\":\"/bar\"}}}" ); + + let event = v7::Event { + request: Some(v7::Request { + url: "https://www.example.invalid/bar".parse().ok(), + method: Some("GET".into()), + data: Some("{}".into()), + query_string: Some("foo=bar&blub=blah".into()), + cookies: Some("dummy=42".into()), + other: { + let mut m = HashMap::new(); + m.insert("other_key".into(), "other_value".into()); + m + }, + ..Default::default() + }), + ..Default::default() + }; + + assert_eq!( + serde_json::to_string(&event).unwrap(), + "{\"request\":{\"url\":\"https://www.example.invalid/bar\",\ + \"method\":\"GET\",\"data\":\"{}\",\"query_string\":\ + \"foo=bar&blub=blah\",\"cookies\":\"dummy=42\",\ + \"other_key\":\"other_value\"}}" + ); + + let event = v7::Event { + request: Some(Default::default()), + ..Default::default() + }; + + assert_eq!( + serde_json::to_string(&event).unwrap(), + "{\"request\":{}}" + ); } #[test]