Skip to content

Commit 35231ea

Browse files
committed
test: validate body of request
1 parent 9b742fd commit 35231ea

File tree

1 file changed

+20
-4
lines changed
  • crates/matrix-sdk/tests/integration/room

1 file changed

+20
-4
lines changed

crates/matrix-sdk/tests/integration/room/joined.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,17 @@ async fn test_make_reply_event_doesnt_require_event_cache() {
776776
async fn test_start_live_location_share_for_room() {
777777
let (client, server) = logged_in_client_with_server().await;
778778

779+
// Validate request body and response, partial body matching due to auto-generated
780+
// `org.matrix.msc3488.ts`
779781
Mock::given(method("PUT"))
780782
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/state/org.matrix.msc3672.beacon_info/.*"))
781783
.and(header("authorization", "Bearer 1234"))
784+
.and(body_partial_json(&json!({
785+
"description": "Live Share",
786+
"live": true,
787+
"timeout": 3000,
788+
"org.matrix.msc3488.asset": { "type": "m.self" }
789+
})))
782790
.respond_with(ResponseTemplate::new(200).set_body_json(&*test_json::EVENT_ID))
783791
.mount(&server)
784792
.await;
@@ -787,7 +795,7 @@ async fn test_start_live_location_share_for_room() {
787795

788796
mock_sync(&server, &*test_json::SYNC, None).await;
789797

790-
let _response = client.sync_once(sync_settings.clone()).await.unwrap();
798+
client.sync_once(sync_settings.clone()).await.unwrap();
791799

792800
let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap();
793801

@@ -834,7 +842,7 @@ async fn test_start_live_location_share_for_room() {
834842
)
835843
.await;
836844

837-
let _response = client.sync_once(sync_settings.clone()).await.unwrap();
845+
client.sync_once(sync_settings.clone()).await.unwrap();
838846
server.reset().await;
839847

840848
let state_events = room.get_state_events(StateEventType::BeaconInfo).await.unwrap();
@@ -867,9 +875,17 @@ async fn test_start_live_location_share_for_room() {
867875
async fn test_stop_sharing_live_location() {
868876
let (client, server) = logged_in_client_with_server().await;
869877

878+
// Validate request body and response, partial body matching due to auto-generated
879+
// `org.matrix.msc3488.ts`
870880
Mock::given(method("PUT"))
871881
.and(path_regex(r"^/_matrix/client/r0/rooms/.*/state/org.matrix.msc3672.beacon_info/.*"))
872882
.and(header("authorization", "Bearer 1234"))
883+
.and(body_partial_json(&json!({
884+
"description": "Live Share",
885+
"live": false,
886+
"timeout": 3000,
887+
"org.matrix.msc3488.asset": { "type": "m.self" }
888+
})))
873889
.respond_with(ResponseTemplate::new(200).set_body_json(&*test_json::EVENT_ID))
874890
.mount(&server)
875891
.await;
@@ -913,7 +929,7 @@ async fn test_stop_sharing_live_location() {
913929
)
914930
.await;
915931

916-
let _response = client.sync_once(sync_settings.clone()).await.unwrap();
932+
client.sync_once(sync_settings.clone()).await.unwrap();
917933

918934
let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap();
919935

@@ -959,7 +975,7 @@ async fn test_stop_sharing_live_location() {
959975
)
960976
.await;
961977

962-
let _response = client.sync_once(sync_settings.clone()).await.unwrap();
978+
client.sync_once(sync_settings.clone()).await.unwrap();
963979
server.reset().await;
964980

965981
let state_events = room.get_state_events(StateEventType::BeaconInfo).await.unwrap();

0 commit comments

Comments
 (0)