Skip to content

Commit

Permalink
test: Added request test
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 23, 2018
1 parent a1436e4 commit 842be0a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_protocol_v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 842be0a

Please sign in to comment.