move Read impl of Body to private function

This commit is contained in:
Sean McArthur
2016-11-21 11:47:07 -08:00
parent 85c8c7bd64
commit a580af2a22
2 changed files with 17 additions and 35 deletions

View File

@@ -291,11 +291,11 @@ impl Read for Response {
#[cfg(test)]
mod tests {
use super::*;
use ::body;
use hyper::method::Method;
use hyper::Url;
use hyper::header::{Host, Headers, ContentType};
use std::collections::HashMap;
use std::io::Read;
use serde_urlencoded;
use serde_json;
@@ -378,8 +378,7 @@ mod tests {
r = r.body(body);
let mut buf = String::new();
r.body.unwrap().unwrap().read_to_string(&mut buf).unwrap();
let buf = body::read_to_string(r.body.unwrap().unwrap()).unwrap();
assert_eq!(buf, body);
}
@@ -398,8 +397,7 @@ mod tests {
// Make sure the content type was set
assert_eq!(r.headers.get::<ContentType>(), Some(&ContentType::form_url_encoded()));
let mut buf = String::new();
r.body.unwrap().unwrap().read_to_string(&mut buf).unwrap();
let buf = body::read_to_string(r.body.unwrap().unwrap()).unwrap();
let body_should_be = serde_urlencoded::to_string(&form_data).unwrap();
assert_eq!(buf, body_should_be);
@@ -419,8 +417,7 @@ mod tests {
// Make sure the content type was set
assert_eq!(r.headers.get::<ContentType>(), Some(&ContentType::json()));
let mut buf = String::new();
r.body.unwrap().unwrap().read_to_string(&mut buf).unwrap();
let buf = body::read_to_string(r.body.unwrap().unwrap()).unwrap();
let body_should_be = serde_json::to_string(&json_data).unwrap();
assert_eq!(buf, body_should_be);