events: Test new prev_content compat code

This commit is contained in:
Jonas Platte 2021-08-16 23:10:58 +02:00
parent 367f4ac0e6
commit f859d543e1
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,36 @@
#![cfg(feature = "compat")]
use matches::assert_matches;
use ruma_events::room::topic::{TopicEvent, TopicEventContent};
use serde_json::{from_value as from_json_value, json};
#[test]
fn deserialize_unsigned_prev_content() {
let res = from_json_value::<TopicEvent>(json!({
"content": {
"topic": "New room topic",
},
"event_id": "$143273582443PhrSn:example.org",
"origin_server_ts": 1432735824653u64,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
"sender": "@example:example.org",
"state_key": "",
"type": "m.room.topic",
"unsigned": {
"age": 1234,
"prev_content": {
"topic": "Old room topic",
},
},
}));
assert_matches!(
res,
Ok(TopicEvent {
content: TopicEventContent { topic: new_topic, .. },
prev_content: Some(TopicEventContent { topic: old_topic, .. }),
..
}) if new_topic == "New room topic"
&& old_topic == "Old room topic"
);
}

View File

@ -66,7 +66,13 @@ impl CiTask {
cmd!("rustup run stable cargo check -p ruma-identifiers --no-default-features").run()?;
// 2. Run tests
cmd!("rustup run stable cargo test --workspace --features full,unstable-pre-spec").run()
let workspace_res =
cmd!("rustup run stable cargo test --workspace --features full,unstable-pre-spec")
.run();
let events_compat_res =
cmd!("rustup run stable cargo test -p ruma-events --features compat compat").run();
workspace_res.and(events_compat_res)
}
fn build_nightly(&self) -> xshell::Result<()> {