test(server): Add test for GET request with body

This commit is contained in:
Karl Hobley
2015-11-29 17:09:55 +00:00
parent 0b05c5903e
commit 1077440c4d

View File

@@ -157,6 +157,24 @@ mod tests {
assert_eq!(read_to_string(req).unwrap(), "".to_owned()); assert_eq!(read_to_string(req).unwrap(), "".to_owned());
} }
#[test]
fn test_get_with_body() {
let mut mock = MockStream::with_input(b"\
GET / HTTP/1.1\r\n\
Host: example.domain\r\n\
Content-Length: 19\r\n\
\r\n\
I'm a good request.\r\n\
");
// FIXME: Use Type ascription
let mock: &mut NetworkStream = &mut mock;
let mut stream = BufReader::new(mock);
let req = Request::new(&mut stream, sock("127.0.0.1:80")).unwrap();
assert_eq!(read_to_string(req).unwrap(), "I'm a good request.".to_owned());
}
#[test] #[test]
fn test_head_empty_body() { fn test_head_empty_body() {
let mut mock = MockStream::with_input(b"\ let mut mock = MockStream::with_input(b"\