From ecf875358cdc360aedd58e69bd05e58ca42c4930 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sun, 16 May 2021 22:53:00 +0200 Subject: [PATCH] events: Fix issues from not testing previous commits --- crates/ruma-events/src/room/third_party_invite.rs | 2 +- crates/ruma-events/tests/redacted.rs | 6 +++--- crates/ruma-events/tests/redaction.rs | 4 ++-- crates/ruma-events/tests/room_message.rs | 2 +- crates/ruma-events/tests/stripped.rs | 6 ++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/ruma-events/src/room/third_party_invite.rs b/crates/ruma-events/src/room/third_party_invite.rs index b5c00f32..07e01a18 100644 --- a/crates/ruma-events/src/room/third_party_invite.rs +++ b/crates/ruma-events/src/room/third_party_invite.rs @@ -47,7 +47,7 @@ impl ThirdPartyInviteEventContent { /// Creates a new `ThirdPartyInviteEventContent` with the given display name, key validity url /// and public key. pub fn new(display_name: String, key_validity_url: String, public_key: String) -> Self { - Self { display_name, key_validity_url, public_key, public_keys } + Self { display_name, key_validity_url, public_key, public_keys: None } } } diff --git a/crates/ruma-events/tests/redacted.rs b/crates/ruma-events/tests/redacted.rs index d7295b4c..32be4fe3 100644 --- a/crates/ruma-events/tests/redacted.rs +++ b/crates/ruma-events/tests/redacted.rs @@ -24,7 +24,7 @@ use serde_json::{ fn unsigned() -> RedactedUnsigned { let mut unsigned = RedactedUnsigned::default(); unsigned.redacted_because = Some(Box::new(SyncRedactionEvent { - content: RedactionEventContent { reason: Some("redacted because".into()) }, + content: RedactionEventContent::with_reason("redacted because".into()), redacts: event_id!("$h29iv0s8:example.com"), event_id: event_id!("$h29iv0s8:example.com"), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), @@ -167,7 +167,7 @@ fn redacted_deserialize_any_room_sync() { // to return early with `RedactedContent` instead of failing to deserialize according // to the event type string. unsigned.redacted_because = Some(Box::new(SyncRedactionEvent { - content: RedactionEventContent { reason: Some("redacted because".into()) }, + content: RedactionEventContent::with_reason("redacted because".into()), redacts: event_id!("$h29iv0s8:example.com"), event_id: event_id!("$h29iv0s8:example.com"), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), @@ -310,7 +310,7 @@ fn redact_method_properly_redacts() { }); let redaction = SyncRedactionEvent { - content: RedactionEventContent { reason: Some("redacted because".into()) }, + content: RedactionEventContent::with_reason("redacted because".into()), redacts: event_id!("$143273582443PhrSn:example.com"), event_id: event_id!("$h29iv0s8:example.com"), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), diff --git a/crates/ruma-events/tests/redaction.rs b/crates/ruma-events/tests/redaction.rs index 9ad13aa0..3bf64ee9 100644 --- a/crates/ruma-events/tests/redaction.rs +++ b/crates/ruma-events/tests/redaction.rs @@ -28,7 +28,7 @@ fn redaction() -> JsonValue { #[test] fn serialize_redaction() { let aliases_event = RedactionEvent { - content: RedactionEventContent { reason: Some("being a turd".into()) }, + content: RedactionEventContent::with_reason("being a turd".into()), redacts: event_id!("$nomore:example.com"), event_id: event_id!("$h29iv0s8:example.com"), origin_server_ts: MilliSecondsSinceUnixEpoch(uint!(1)), @@ -53,7 +53,7 @@ fn deserialize_redaction() { .deserialize() .unwrap(), AnyMessageEvent::RoomRedaction(RedactionEvent { - content: RedactionEventContent { reason: Some(reas) }, + content: RedactionEventContent { reason: Some(reas), .. }, redacts, event_id, origin_server_ts, diff --git a/crates/ruma-events/tests/room_message.rs b/crates/ruma-events/tests/room_message.rs index 01d1c164..eb0699bb 100644 --- a/crates/ruma-events/tests/room_message.rs +++ b/crates/ruma-events/tests/room_message.rs @@ -160,7 +160,7 @@ fn relates_to_content_serialization() { let message_event_content = assign!(MessageEventContent::text_plain("> <@test:example.com> test\n\ntest reply"), { relates_to: Some(Relation::Reply { - in_reply_to: InReplyTo { event_id: event_id!("$15827405538098VGFWH:example.com") }, + in_reply_to: InReplyTo::new(event_id!("$15827405538098VGFWH:example.com")), }), }); diff --git a/crates/ruma-events/tests/stripped.rs b/crates/ruma-events/tests/stripped.rs index 7ddd231c..eff66dce 100644 --- a/crates/ruma-events/tests/stripped.rs +++ b/crates/ruma-events/tests/stripped.rs @@ -9,9 +9,7 @@ use serde_json::{from_value as from_json_value, json, to_value as to_json_value} #[test] fn serialize_stripped_state_event_any_content() { let event = StrippedStateEvent { - content: AnyStateEventContent::RoomTopic(TopicEventContent { - topic: "Testing room".into(), - }), + content: AnyStateEventContent::RoomTopic(TopicEventContent::new("Testing room".into())), state_key: "".into(), sender: user_id!("@example:localhost"), }; @@ -31,7 +29,7 @@ fn serialize_stripped_state_event_any_content() { #[test] fn serialize_stripped_state_event_any_event() { let event = AnyStrippedStateEvent::RoomTopic(StrippedStateEvent { - content: TopicEventContent { topic: "Testing room".into() }, + content: TopicEventContent::new("Testing room".into()), state_key: "".into(), sender: user_id!("@example:localhost"), });