move Read impl of Body to private function
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user