From a7a16ccfccc5d3c71470af74ec4cc66adc9a5a11 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 10 Jun 2020 00:20:01 +0200 Subject: [PATCH] Delete old tests --- tests_backup/ruma_events_macros.rs | 132 ----------------------------- 1 file changed, 132 deletions(-) delete mode 100644 tests_backup/ruma_events_macros.rs diff --git a/tests_backup/ruma_events_macros.rs b/tests_backup/ruma_events_macros.rs deleted file mode 100644 index 17450fdb..00000000 --- a/tests_backup/ruma_events_macros.rs +++ /dev/null @@ -1,132 +0,0 @@ -use std::{ - collections::BTreeMap, - convert::TryFrom, - time::{Duration, UNIX_EPOCH}, -}; - -use js_int::Int; -use maplit::btreemap; -use matches::assert_matches; -use ruma_events::{EventJson, UnsignedData}; -use ruma_events_macros::ruma_event; -use ruma_identifiers::{RoomAliasId, RoomId, UserId}; -use serde_json::{from_value as from_json_value, json}; - -mod extra_fields { - use super::*; - - ruma_event! { - /// A redaction of an event. - RedactionEvent { - kind: RoomEvent, - event_type: "m.room.redaction", - fields: { - /// The ID of the event that was redacted. - pub redacts: ruma_identifiers::EventId - }, - content: { - /// The reason for the redaction, if any. - pub reason: Option, - }, - } - } - - #[test] - fn field_serialization_deserialization() { - let json = json!({ - "content": { - "reason": null - }, - "event_id": "$h29iv0s8:example.com", - "origin_server_ts": 1, - "redacts": "$h29iv0s8:example.com", - "room_id": "!n8f893n9:example.com", - "sender": "@carl:example.com", - "unsigned": { - "age": 100 - }, - "type": "m.room.redaction" - }); - - assert_matches!( - from_json_value::>(json) - .unwrap() - .deserialize() - .unwrap(), - RedactionEvent { - content: RedactionEventContent { reason: None }, - redacts, - event_id, - origin_server_ts, - room_id: Some(room_id), - sender, - unsigned: UnsignedData { - age: Some(age), - redacted_because: None, - transaction_id: None, - }, - } if redacts == "$h29iv0s8:example.com" - && event_id == "$h29iv0s8:example.com" - && origin_server_ts == UNIX_EPOCH + Duration::from_millis(1) - && room_id == "!n8f893n9:example.com" - && sender == "@carl:example.com" - && age == Int::from(100) - ); - } -} - -mod type_alias { - use super::*; - - ruma_event! { - /// Informs the client about the rooms that are considered direct by a user. - DirectEvent { - kind: Event, - event_type: "m.direct", - content_type_alias: { - /// The payload of a `DirectEvent`. - /// - /// A mapping of `UserId`'s to a collection of `RoomId`'s which are considered - /// *direct* for that particular user. - BTreeMap> - } - } - } - - #[test] - fn alias_is_not_empty() { - let json = json!({ - "content": { - "@bob:example.com": ["!n8f893n9:example.com"] - }, - "type": "m.direct" - }); - - let event = from_json_value::>(json) - .unwrap() - .deserialize() - .unwrap(); - - assert_eq!( - event.content, - btreemap! { - UserId::try_from("@bob:example.com").unwrap() => vec![ - RoomId::try_from("!n8f893n9:example.com").unwrap() - ] - } - ); - } - - #[test] - fn alias_empty() { - let json = json!({ - "content": {}, - "type": "m.direct" - }); - - let _ = from_json_value::>(json) - .unwrap() - .deserialize() - .unwrap(); - } -}