mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Fix serialize missing ID response
This commit is contained in:
parent
0afb26e143
commit
c0b6fd6ccb
3 changed files with 28 additions and 4 deletions
|
|
@ -267,7 +267,7 @@ impl ApiService {
|
||||||
|
|
||||||
response_dom.transfer_within(child_ref, object_value);
|
response_dom.transfer_within(child_ref, object_value);
|
||||||
} else {
|
} else {
|
||||||
msgpack(
|
return msgpack(
|
||||||
ErrorResponse::bad_request(format!("provided id {id} is not in the tree")),
|
ErrorResponse::bad_request(format!("provided id {id} is not in the tree")),
|
||||||
StatusCode::BAD_REQUEST,
|
StatusCode::BAD_REQUEST,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,16 @@ impl TestServeSession {
|
||||||
ids: &[Ref],
|
ids: &[Ref],
|
||||||
session_id: SessionId,
|
session_id: SessionId,
|
||||||
) -> Result<SerializeResponse, reqwest::Error> {
|
) -> 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(
|
||||||
|
&self,
|
||||||
|
ids: &[Ref],
|
||||||
|
session_id: SessionId,
|
||||||
|
) -> Result<reqwest::blocking::Response, reqwest::Error> {
|
||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let url = format!("http://localhost:{}/api/serialize", self.port);
|
let url = format!("http://localhost:{}/api/serialize", self.port);
|
||||||
let body = serialize_msgpack(&SerializeRequest {
|
let body = serialize_msgpack(&SerializeRequest {
|
||||||
|
|
@ -237,9 +247,7 @@ impl TestServeSession {
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let body = client.post(url).body(body).send()?.bytes()?;
|
client.post(url).body(body).send()
|
||||||
|
|
||||||
Ok(deserialize_msgpack(&body).expect("Server returned malformed response"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use insta::{assert_snapshot, assert_yaml_snapshot, with_settings};
|
use insta::{assert_snapshot, assert_yaml_snapshot, with_settings};
|
||||||
|
use rbx_dom_weak::types::Ref;
|
||||||
|
use reqwest::StatusCode;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
use crate::rojo_test::{
|
use crate::rojo_test::{
|
||||||
|
|
@ -659,6 +661,20 @@ fn meshpart_with_id() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_missing_id() {
|
||||||
|
run_serve_test("empty", |session, _| {
|
||||||
|
let info = session.get_api_rojo().unwrap();
|
||||||
|
let missing_id = Ref::new();
|
||||||
|
|
||||||
|
let response = session
|
||||||
|
.post_api_serialize(&[missing_id], info.session_id)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn forced_parent() {
|
fn forced_parent() {
|
||||||
run_serve_test("forced_parent", |session, mut redactions| {
|
run_serve_test("forced_parent", |session, mut redactions| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue