Skip to content

Commit

Permalink
test: get rid of more instances of sync_timeline_event! in the sdk …
Browse files Browse the repository at this point in the history
…crate
  • Loading branch information
bnjbvr committed Jan 21, 2025
1 parent 3c916b4 commit 882e7a6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 38 deletions.
19 changes: 7 additions & 12 deletions crates/matrix-sdk/src/event_cache/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,11 @@ mod tests {

use assert_matches::assert_matches;
use matrix_sdk_base::RoomState;
use matrix_sdk_test::{
async_test, event_factory::EventFactory, sync_timeline_event, ALICE,
};
use ruma::room_id;
use matrix_sdk_test::{async_test, event_factory::EventFactory, ALICE};
use ruma::{event_id, room_id, user_id};
use tokio::{spawn, time::sleep};

use crate::{
deserialized_responses::SyncTimelineEvent,
event_cache::{pagination::PaginationToken, room::events::Gap},
test_utils::logged_in_client,
};
Expand Down Expand Up @@ -541,13 +538,11 @@ mod tests {
.await
.with_events_mut(|room_events| {
room_events.push_gap(Gap { prev_token: expected_token.clone() });
room_events.push_events([SyncTimelineEvent::new(sync_timeline_event!({
"sender": "[email protected]",
"type": "m.room.message",
"event_id": "$ida",
"origin_server_ts": 12344446,
"content": { "body":"yolo", "msgtype": "m.text" },
}))]);
room_events.push_events([EventFactory::new()
.text_msg("yolo")
.sender(user_id!("@b:z.h"))
.event_id(event_id!("$ida"))
.into_sync()]);
})
.await
.unwrap();
Expand Down
40 changes: 14 additions & 26 deletions crates/matrix-sdk/src/event_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,9 @@ where
#[cfg(test)]
mod tests {
use matrix_sdk_test::{
async_test, InvitedRoomBuilder, JoinedRoomBuilder, DEFAULT_TEST_ROOM_ID,
async_test,
event_factory::{EventFactory, PreviousMembership},
InvitedRoomBuilder, JoinedRoomBuilder, DEFAULT_TEST_ROOM_ID,
};
use stream_assert::{assert_closed, assert_pending, assert_ready};
#[cfg(target_arch = "wasm32")]
Expand All @@ -686,14 +688,14 @@ mod tests {
};

use matrix_sdk_test::{
sync_timeline_event, EphemeralTestEvent, StateTestEvent, StrippedStateTestEvent,
SyncResponseBuilder,
EphemeralTestEvent, StateTestEvent, StrippedStateTestEvent, SyncResponseBuilder,
};
use once_cell::sync::Lazy;
use ruma::{
event_id,
events::{
room::{
member::{OriginalSyncRoomMemberEvent, StrippedRoomMemberEvent},
member::{MembershipState, OriginalSyncRoomMemberEvent, StrippedRoomMemberEvent},
name::OriginalSyncRoomNameEvent,
power_levels::OriginalSyncRoomPowerLevelsEvent,
},
Expand All @@ -702,6 +704,7 @@ mod tests {
},
room_id,
serde::Raw,
user_id,
};
use serde_json::json;

Expand All @@ -712,28 +715,13 @@ mod tests {
};

static MEMBER_EVENT: Lazy<Raw<AnySyncTimelineEvent>> = Lazy::new(|| {
sync_timeline_event!({
"content": {
"avatar_url": null,
"displayname": "example",
"membership": "join"
},
"event_id": "$151800140517rfvjc:localhost",
"membership": "join",
"origin_server_ts": 151800140,
"sender": "@example:localhost",
"state_key": "@example:localhost",
"type": "m.room.member",
"prev_content": {
"avatar_url": null,
"displayname": "example",
"membership": "invite"
},
"unsigned": {
"age": 297036,
"replaces_state": "$151800111315tsynI:localhost"
}
})
EventFactory::new()
.member(user_id!("@example:localhost"))
.membership(MembershipState::Join)
.display_name("example")
.event_id(event_id!("$151800140517rfvjc:localhost"))
.previous(PreviousMembership::new(MembershipState::Invite).display_name("example"))
.into()
});

#[async_test]
Expand Down

0 comments on commit 882e7a6

Please sign in to comment.