Skip to content

Commit bfac815

Browse files
committed
test: EventBuilder<RoomCreateEventContent> can set predecessor.
This patch adds the `predecessor` and `no_predecessor` methods on `EventBuilder<RoomCreateEventContent>`. This is helpful to configure the `predecessor` field.
1 parent 95e8d05 commit bfac815

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

testing/matrix-sdk-test/src/event_factory.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use ruma::{
4141
room::{
4242
avatar::{self, RoomAvatarEventContent},
4343
canonical_alias::RoomCanonicalAliasEventContent,
44-
create::RoomCreateEventContent,
44+
create::{PreviousRoom, RoomCreateEventContent},
4545
encrypted::{EncryptedEventScheme, RoomEncryptedEventContent},
4646
member::{MembershipState, RoomMemberEventContent},
4747
message::{
@@ -400,6 +400,20 @@ impl EventBuilder<UnstablePollStartEventContent> {
400400
}
401401
}
402402

403+
impl EventBuilder<RoomCreateEventContent> {
404+
/// Define the predecessor fields.
405+
pub fn predecessor(mut self, room_id: &RoomId, event_id: &EventId) -> Self {
406+
self.content.predecessor = Some(PreviousRoom::new(room_id.to_owned(), event_id.to_owned()));
407+
self
408+
}
409+
410+
/// Erase the predecessor if any.
411+
pub fn no_predecessor(mut self) -> Self {
412+
self.content.predecessor = None;
413+
self
414+
}
415+
}
416+
403417
impl<E: EventContent> From<EventBuilder<E>> for Raw<AnySyncTimelineEvent>
404418
where
405419
E::EventType: Serialize,

0 commit comments

Comments
 (0)