Keep the old Response::into_json around and call this Response::into_json_deserialize

This commit is contained in:
Paolo Barbolini
2020-05-04 21:45:27 +02:00
committed by Martin Algesten
parent 0b69c595b6
commit 4e744f87c1
3 changed files with 63 additions and 6 deletions

View File

@@ -61,6 +61,22 @@ fn body_as_text() {
#[test]
#[cfg(feature = "json")]
fn body_as_json() {
test::set_handler("/body_as_json", |_unit| {
test::make_response(
200,
"OK",
vec![],
"{\"hello\":\"world\"}".to_string().into_bytes(),
)
});
let resp = get("test://host/body_as_json").call();
let json = resp.into_json().unwrap();
assert_eq!(json["hello"], "world");
}
#[test]
#[cfg(feature = "json")]
fn body_as_json_deserialize() {
use serde::Deserialize;
#[derive(Deserialize)]
@@ -77,7 +93,7 @@ fn body_as_json() {
)
});
let resp = get("test://host/body_as_json").call();
let json = resp.into_json::<Hello>().unwrap();
let json = resp.into_json_deserialize::<Hello>().unwrap();
assert_eq!(json.hello, "world");
}