Clean up json! formatting

This commit is contained in:
Jonas Platte 2021-05-14 01:13:42 +02:00
parent 5710d2740c
commit fe68bf0e07
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
6 changed files with 21 additions and 21 deletions

View File

@ -88,7 +88,7 @@ fn serialize_pdu_as_v3() {
signatures.insert(server_name!("example.com"), inner_signature); signatures.insert(server_name!("example.com"), inner_signature);
let mut unsigned = BTreeMap::new(); let mut unsigned = BTreeMap::new();
unsigned.insert("somekey".into(), json!({"a": 456})); unsigned.insert("somekey".into(), json!({ "a": 456 }));
let v3_pdu = RoomV3Pdu { let v3_pdu = RoomV3Pdu {
room_id: room_id!("!n8f893n9:example.com"), room_id: room_id!("!n8f893n9:example.com"),

View File

@ -146,7 +146,7 @@ mod tests {
#[test] #[test]
fn too_long_array() { fn too_long_array() {
let json = json!([200, {"origin": "", "auth_chain": [], "state": []}, 200]); let json = json!([200, { "origin": "", "auth_chain": [], "state": [] }, 200]);
assert_matches!( assert_matches!(
deserialize(json).unwrap(), deserialize(json).unwrap(),
RoomState { origin, auth_chain, state } RoomState { origin, auth_chain, state }

View File

@ -420,7 +420,7 @@ fn INITIAL_EVENTS() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice().to_string(): 100}}), json!({ "users": { alice().to_string(): 100 } }),
&["CREATE", "IMA"], &["CREATE", "IMA"],
&["IMA"], &["IMA"],
), ),
@ -484,7 +484,7 @@ fn BAN_STATE_SET() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
&["CREATE", "IMA", "IPOWER"], // auth_events &["CREATE", "IMA", "IPOWER"], // auth_events
&["START"], // prev_events &["START"], // prev_events
), ),
@ -493,7 +493,7 @@ fn BAN_STATE_SET() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
&["CREATE", "IMA", "IPOWER"], &["CREATE", "IMA", "IPOWER"],
&["END"], &["END"],
), ),

View File

@ -123,7 +123,7 @@ fn BAN_STATE_SET() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
&["CREATE", "IMA", "IPOWER"], // auth_events &["CREATE", "IMA", "IPOWER"], // auth_events
&["START"], // prev_events &["START"], // prev_events
), ),
@ -132,7 +132,7 @@ fn BAN_STATE_SET() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
&["CREATE", "IMA", "IPOWER"], &["CREATE", "IMA", "IPOWER"],
&["END"], &["END"],
), ),
@ -168,7 +168,7 @@ fn JOIN_RULE() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomJoinRules, EventType::RoomJoinRules,
Some(""), Some(""),
json!({"join_rule": "invite"}), json!({ "join_rule": "invite" }),
&["CREATE", "IMA", "IPOWER"], &["CREATE", "IMA", "IPOWER"],
&["START"], &["START"],
), ),

View File

@ -23,7 +23,7 @@ fn ban_vs_power_level() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
), ),
to_init_pdu_event( to_init_pdu_event(
"MA", "MA",
@ -44,7 +44,7 @@ fn ban_vs_power_level() {
bob(), bob(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
), ),
]; ];
@ -67,7 +67,7 @@ fn topic_basic() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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("T2", alice(), EventType::RoomTopic, Some(""), json!({})),
to_init_pdu_event( to_init_pdu_event(
@ -75,14 +75,14 @@ fn topic_basic() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 0}}), json!({ "users": { alice(): 100, bob(): 0 } }),
), ),
to_init_pdu_event( to_init_pdu_event(
"PB", "PB",
bob(), bob(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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("T3", bob(), EventType::RoomTopic, Some(""), json!({})),
]; ];
@ -107,7 +107,7 @@ fn topic_reset() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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("T2", bob(), EventType::RoomTopic, Some(""), json!({})),
to_init_pdu_event( to_init_pdu_event(
@ -166,21 +166,21 @@ fn offtopic_power_level() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50}}), json!({ "users": { alice(): 100, bob(): 50 } }),
), ),
to_init_pdu_event( to_init_pdu_event(
"PB", "PB",
bob(), bob(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 50, charlie(): 50}}), json!({ "users": { alice(): 100, bob(): 50, charlie(): 50 } }),
), ),
to_init_pdu_event( to_init_pdu_event(
"PC", "PC",
charlie(), charlie(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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("T2", alice(), EventType::RoomTopic, Some(""), json!({})),
to_init_pdu_event( to_init_pdu_event(
@ -211,14 +211,14 @@ fn topic_setting() {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice(): 100, bob(): 0}}), json!({ "users": { alice(): 100, bob(): 0 } }),
), ),
to_init_pdu_event( to_init_pdu_event(
"PB", "PB",
bob(), bob(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), 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("T3", bob(), EventType::RoomTopic, Some(""), json!({})),
to_init_pdu_event("MZ1", zara(), EventType::RoomTopic, Some(""), json!({})), to_init_pdu_event("MZ1", zara(), EventType::RoomTopic, Some(""), json!({})),

View File

@ -433,7 +433,7 @@ pub fn INITIAL_EVENTS() -> BTreeMap<EventId, Arc<StateEvent>> {
alice(), alice(),
EventType::RoomPowerLevels, EventType::RoomPowerLevels,
Some(""), Some(""),
json!({"users": {alice().to_string(): 100}}), json!({ "users": { alice().to_string(): 100 } }),
&["CREATE", "IMA"], &["CREATE", "IMA"],
&["IMA"], &["IMA"],
), ),