events: Test new prev_content compat code
This commit is contained in:
parent
367f4ac0e6
commit
f859d543e1
36
crates/ruma-events/tests/compat.rs
Normal file
36
crates/ruma-events/tests/compat.rs
Normal 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"
|
||||||
|
);
|
||||||
|
}
|
@ -66,7 +66,13 @@ impl CiTask {
|
|||||||
cmd!("rustup run stable cargo check -p ruma-identifiers --no-default-features").run()?;
|
cmd!("rustup run stable cargo check -p ruma-identifiers --no-default-features").run()?;
|
||||||
|
|
||||||
// 2. Run tests
|
// 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<()> {
|
fn build_nightly(&self) -> xshell::Result<()> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user