federation-api: Add a test for v1 /send_join response serialization

Co-authored-by: Timo Kösters <timo@koesters.xyz>
This commit is contained in:
Jonas Platte 2021-08-17 00:20:10 +02:00
parent b9486b91fa
commit 15553e1da9
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -54,3 +54,23 @@ impl Response {
Self { room_state }
}
}
#[cfg(all(test, feature = "server", not(feature = "unstable-pre-spec")))]
mod tests {
use ruma_api::OutgoingResponse;
use serde_json::{from_slice as from_json_slice, json, Value as JsonValue};
use super::{super::RoomState, Response};
#[test]
fn response_body() {
let res = Response::new(RoomState::new("ORIGIN".to_owned()))
.try_into_http_response::<Vec<u8>>()
.unwrap();
assert_eq!(
from_json_slice::<JsonValue>(res.body()).unwrap(),
json!([200, { "auth_chain": [], "origin": "ORIGIN", "state": [] }])
);
}
}