From fe68bf0e075860e3f20b448792c1d32c88574f0d Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 14 May 2021 01:13:42 +0200 Subject: [PATCH] Clean up json! formatting --- crates/ruma-events/tests/pdu.rs | 2 +- .../ruma-federation-api/src/serde/v1_pdu.rs | 2 +- .../ruma-state-res/benches/state_res_bench.rs | 6 ++--- .../ruma-state-res/tests/res_with_auth_ids.rs | 6 ++--- crates/ruma-state-res/tests/state_res.rs | 24 +++++++++---------- crates/ruma-state-res/tests/utils.rs | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/crates/ruma-events/tests/pdu.rs b/crates/ruma-events/tests/pdu.rs index 9ed57b3f..dfa76817 100644 --- a/crates/ruma-events/tests/pdu.rs +++ b/crates/ruma-events/tests/pdu.rs @@ -88,7 +88,7 @@ fn serialize_pdu_as_v3() { signatures.insert(server_name!("example.com"), inner_signature); let mut unsigned = BTreeMap::new(); - unsigned.insert("somekey".into(), json!({"a": 456})); + unsigned.insert("somekey".into(), json!({ "a": 456 })); let v3_pdu = RoomV3Pdu { room_id: room_id!("!n8f893n9:example.com"), diff --git a/crates/ruma-federation-api/src/serde/v1_pdu.rs b/crates/ruma-federation-api/src/serde/v1_pdu.rs index edd38314..e384824a 100644 --- a/crates/ruma-federation-api/src/serde/v1_pdu.rs +++ b/crates/ruma-federation-api/src/serde/v1_pdu.rs @@ -146,7 +146,7 @@ mod tests { #[test] fn too_long_array() { - let json = json!([200, {"origin": "", "auth_chain": [], "state": []}, 200]); + let json = json!([200, { "origin": "", "auth_chain": [], "state": [] }, 200]); assert_matches!( deserialize(json).unwrap(), RoomState { origin, auth_chain, state } diff --git a/crates/ruma-state-res/benches/state_res_bench.rs b/crates/ruma-state-res/benches/state_res_bench.rs index 68355925..5d2a0b86 100644 --- a/crates/ruma-state-res/benches/state_res_bench.rs +++ b/crates/ruma-state-res/benches/state_res_bench.rs @@ -420,7 +420,7 @@ fn INITIAL_EVENTS() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice().to_string(): 100}}), + json!({ "users": { alice().to_string(): 100 } }), &["CREATE", "IMA"], &["IMA"], ), @@ -484,7 +484,7 @@ fn BAN_STATE_SET() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), &["CREATE", "IMA", "IPOWER"], // auth_events &["START"], // prev_events ), @@ -493,7 +493,7 @@ fn BAN_STATE_SET() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), &["CREATE", "IMA", "IPOWER"], &["END"], ), diff --git a/crates/ruma-state-res/tests/res_with_auth_ids.rs b/crates/ruma-state-res/tests/res_with_auth_ids.rs index 62adbff5..5a964a20 100644 --- a/crates/ruma-state-res/tests/res_with_auth_ids.rs +++ b/crates/ruma-state-res/tests/res_with_auth_ids.rs @@ -123,7 +123,7 @@ fn BAN_STATE_SET() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), &["CREATE", "IMA", "IPOWER"], // auth_events &["START"], // prev_events ), @@ -132,7 +132,7 @@ fn BAN_STATE_SET() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), &["CREATE", "IMA", "IPOWER"], &["END"], ), @@ -168,7 +168,7 @@ fn JOIN_RULE() -> BTreeMap> { alice(), EventType::RoomJoinRules, Some(""), - json!({"join_rule": "invite"}), + json!({ "join_rule": "invite" }), &["CREATE", "IMA", "IPOWER"], &["START"], ), diff --git a/crates/ruma-state-res/tests/state_res.rs b/crates/ruma-state-res/tests/state_res.rs index afe20df0..f5483d42 100644 --- a/crates/ruma-state-res/tests/state_res.rs +++ b/crates/ruma-state-res/tests/state_res.rs @@ -23,7 +23,7 @@ fn ban_vs_power_level() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event( "MA", @@ -44,7 +44,7 @@ fn ban_vs_power_level() { bob(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), ]; @@ -67,7 +67,7 @@ fn topic_basic() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event("T2", alice(), EventType::RoomTopic, Some(""), json!({})), to_init_pdu_event( @@ -75,14 +75,14 @@ fn topic_basic() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 0}}), + json!({ "users": { alice(): 100, bob(): 0 } }), ), to_init_pdu_event( "PB", bob(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event("T3", bob(), EventType::RoomTopic, Some(""), json!({})), ]; @@ -107,7 +107,7 @@ fn topic_reset() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event("T2", bob(), EventType::RoomTopic, Some(""), json!({})), to_init_pdu_event( @@ -166,21 +166,21 @@ fn offtopic_power_level() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event( "PB", bob(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50, charlie(): 50}}), + json!({ "users": { alice(): 100, bob(): 50, charlie(): 50 } }), ), to_init_pdu_event( "PC", charlie(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50, charlie(): 0}}), + json!({ "users": { alice(): 100, bob(): 50, charlie(): 0 } }), ), ]; @@ -203,7 +203,7 @@ fn topic_setting() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event("T2", alice(), EventType::RoomTopic, Some(""), json!({})), to_init_pdu_event( @@ -211,14 +211,14 @@ fn topic_setting() { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 0}}), + json!({ "users": { alice(): 100, bob(): 0 } }), ), to_init_pdu_event( "PB", bob(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice(): 100, bob(): 50}}), + json!({ "users": { alice(): 100, bob(): 50 } }), ), to_init_pdu_event("T3", bob(), EventType::RoomTopic, Some(""), json!({})), to_init_pdu_event("MZ1", zara(), EventType::RoomTopic, Some(""), json!({})), diff --git a/crates/ruma-state-res/tests/utils.rs b/crates/ruma-state-res/tests/utils.rs index fb863280..8edc8525 100644 --- a/crates/ruma-state-res/tests/utils.rs +++ b/crates/ruma-state-res/tests/utils.rs @@ -433,7 +433,7 @@ pub fn INITIAL_EVENTS() -> BTreeMap> { alice(), EventType::RoomPowerLevels, Some(""), - json!({"users": {alice().to_string(): 100}}), + json!({ "users": { alice().to_string(): 100 } }), &["CREATE", "IMA"], &["IMA"], ),