mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Address serialize helper review
This commit is contained in:
parent
5c875f04fe
commit
722348c453
2 changed files with 15 additions and 17 deletions
|
|
@ -224,16 +224,6 @@ impl TestServeSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_api_serialize(
|
|
||||||
&self,
|
|
||||||
ids: &[Ref],
|
|
||||||
session_id: SessionId,
|
|
||||||
) -> Result<SerializeResponse, reqwest::Error> {
|
|
||||||
let body = self.post_api_serialize(ids, session_id)?.bytes()?;
|
|
||||||
|
|
||||||
Ok(deserialize_msgpack(&body).expect("Server returned malformed response"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn post_api_serialize(
|
pub fn post_api_serialize(
|
||||||
&self,
|
&self,
|
||||||
ids: &[Ref],
|
ids: &[Ref],
|
||||||
|
|
@ -262,7 +252,7 @@ fn serialize_msgpack<T: Serialize>(value: T) -> Result<Vec<u8>, rmp_serde::encod
|
||||||
Ok(serialized)
|
Ok(serialized)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_msgpack<'a, T: Deserialize<'a>>(
|
pub fn deserialize_msgpack<'a, T: Deserialize<'a>>(
|
||||||
input: &'a [u8],
|
input: &'a [u8],
|
||||||
) -> Result<T, rmp_serde::decode::Error> {
|
) -> Result<T, rmp_serde::decode::Error> {
|
||||||
let mut deserializer = rmp_serde::Deserializer::new(input).with_human_readable();
|
let mut deserializer = rmp_serde::Deserializer::new(input).with_human_readable();
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ use tempfile::tempdir;
|
||||||
|
|
||||||
use crate::rojo_test::{
|
use crate::rojo_test::{
|
||||||
internable::InternAndRedact,
|
internable::InternAndRedact,
|
||||||
serve_util::{run_serve_test, serialize_to_xml_model},
|
serve_util::{deserialize_msgpack, run_serve_test, serialize_to_xml_model},
|
||||||
};
|
};
|
||||||
|
|
||||||
use librojo::web_api::SocketPacketType;
|
use librojo::web_api::{SerializeResponse, SocketPacketType};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty() {
|
fn empty() {
|
||||||
|
|
@ -647,9 +647,13 @@ fn meshpart_with_id() {
|
||||||
.find(|(_, inst)| inst.class_name == "ObjectValue")
|
.find(|(_, inst)| inst.class_name == "ObjectValue")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let serialize_response = session
|
let body = session
|
||||||
.get_api_serialize(&[*meshpart, *objectvalue], info.session_id)
|
.post_api_serialize(&[*meshpart, *objectvalue], info.session_id)
|
||||||
|
.unwrap()
|
||||||
|
.bytes()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let serialize_response: SerializeResponse =
|
||||||
|
deserialize_msgpack(&body).expect("Server returned malformed response");
|
||||||
|
|
||||||
// We don't assert a snapshot on the SerializeResponse because the model includes the
|
// We don't assert a snapshot on the SerializeResponse because the model includes the
|
||||||
// Refs from the DOM as names, which means it will obviously be different every time
|
// Refs from the DOM as names, which means it will obviously be different every time
|
||||||
|
|
@ -689,9 +693,13 @@ fn forced_parent() {
|
||||||
read_response.intern_and_redact(&mut redactions, root_id)
|
read_response.intern_and_redact(&mut redactions, root_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
let serialize_response = session
|
let body = session
|
||||||
.get_api_serialize(&[root_id], info.session_id)
|
.post_api_serialize(&[root_id], info.session_id)
|
||||||
|
.unwrap()
|
||||||
|
.bytes()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let serialize_response: SerializeResponse =
|
||||||
|
deserialize_msgpack(&body).expect("Server returned malformed response");
|
||||||
|
|
||||||
assert_eq!(serialize_response.session_id, info.session_id);
|
assert_eq!(serialize_response.session_id, info.session_id);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue