appservice-api: Fix helper_tests
This commit is contained in:
parent
9e736bec84
commit
4cefb9ef62
@ -109,15 +109,16 @@ pub mod v1 {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod helper_tests {
|
mod helper_tests {
|
||||||
use ruma_client_api::sync::sync_events;
|
use ruma_client_api::sync::sync_events;
|
||||||
use ruma_identifiers::room_id;
|
use ruma_identifiers::{room_id, TransactionId};
|
||||||
use serde_json::json;
|
use serde_json::{json, value::to_raw_value as to_raw_json_value};
|
||||||
|
|
||||||
use super::{AnyRoomEvent, IncomingRequest, Raw};
|
use super::{IncomingRequest, Raw};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn convert_incoming_request_to_sync_response() {
|
fn convert_incoming_request_to_sync_response() {
|
||||||
let txn_id = "any_txn_id".to_owned();
|
let txn_id = <&TransactionId>::from("any_txn_id");
|
||||||
let state_event: AnyRoomEvent = serde_json::from_value(json!({
|
let state_event = Raw::from_json(
|
||||||
|
to_raw_json_value(&json!({
|
||||||
"content": {},
|
"content": {},
|
||||||
"event_id": "$h29iv0s8:example.com",
|
"event_id": "$h29iv0s8:example.com",
|
||||||
"origin_server_ts": 1,
|
"origin_server_ts": 1,
|
||||||
@ -126,8 +127,10 @@ pub mod v1 {
|
|||||||
"state_key": "",
|
"state_key": "",
|
||||||
"type": "m.room.name"
|
"type": "m.room.name"
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap(),
|
||||||
let message_event: AnyRoomEvent = serde_json::from_value(json!({
|
);
|
||||||
|
let message_event = Raw::from_json(
|
||||||
|
to_raw_json_value(&json!({
|
||||||
"type": "m.room.message",
|
"type": "m.room.message",
|
||||||
"event_id": "$143273582443PhrSn:example.com",
|
"event_id": "$143273582443PhrSn:example.com",
|
||||||
"origin_server_ts": 1,
|
"origin_server_ts": 1,
|
||||||
@ -139,13 +142,14 @@ pub mod v1 {
|
|||||||
"url": "mxc://example.com/AuDi0",
|
"url": "mxc://example.com/AuDi0",
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
let events = vec![Raw::new(&state_event).unwrap(), Raw::new(&message_event).unwrap()];
|
let events = vec![state_event, message_event];
|
||||||
let incoming_request = IncomingRequest { txn_id: txn_id.clone(), events };
|
let incoming_request = IncomingRequest { txn_id: txn_id.into(), events };
|
||||||
|
|
||||||
let response: sync_events::Response =
|
let response: sync_events::v3::Response =
|
||||||
incoming_request.try_into_sync_response(txn_id).unwrap();
|
incoming_request.try_into_sync_response("token").unwrap();
|
||||||
|
|
||||||
let response_rooms_join = response
|
let response_rooms_join = response
|
||||||
.rooms
|
.rooms
|
||||||
|
Loading…
x
Reference in New Issue
Block a user