mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
dab50b1ec3
Fixed test. Signed-off-by: Jonathan Sutton <jonathansutton91@proton.me>
35 lines
905 B
Rust
35 lines
905 B
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn test_strip_room_member() -> Result<()> {
|
|
//Test setup
|
|
let body = r#"
|
|
{
|
|
"avatar_url": "Something",
|
|
"displayname": "Someone",
|
|
"join_authorized_via_users_server": "@someone:domain.tld",
|
|
"membership": "join"
|
|
}"#;
|
|
println!("JSON (original): {body}");
|
|
let json: &mut Raw<AnyStateEventContent> =
|
|
&mut Raw::<AnyStateEventContent>::from_json_string(body.to_owned())?;
|
|
let mut membership_content: RoomMemberEventContent =
|
|
json.deserialize_as::<RoomMemberEventContent>()?;
|
|
|
|
//Begin Test
|
|
membership_content.join_authorized_via_users_server = None;
|
|
*json = Raw::<AnyStateEventContent>::from_json_string(serde_json::to_string(
|
|
&membership_content,
|
|
)?)?;
|
|
|
|
//Compare result
|
|
let result = json.json().get();
|
|
println!("JSON (modified): {result}");
|
|
assert_eq!(
|
|
result,
|
|
r#"{"avatar_url":"Something","displayname":"Someone","membership":"join"}"#
|
|
);
|
|
|
|
Ok(())
|
|
}
|