state-res: Clean up test code
This commit is contained in:
parent
62b0034a83
commit
69a97232b9
@ -836,7 +836,7 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
event_auth::valid_membership_change,
|
event_auth::valid_membership_change,
|
||||||
test_utils::{
|
test_utils::{
|
||||||
alice, charlie, event_id, member_content_ban, to_pdu_event, StateEvent, INITIAL_EVENTS,
|
alice, charlie, member_content_ban, to_pdu_event, StateEvent, INITIAL_EVENTS,
|
||||||
},
|
},
|
||||||
Event, StateMap,
|
Event, StateMap,
|
||||||
};
|
};
|
||||||
@ -865,7 +865,7 @@ mod tests {
|
|||||||
Some(charlie().as_str()),
|
Some(charlie().as_str()),
|
||||||
member_content_ban(),
|
member_content_ban(),
|
||||||
&[],
|
&[],
|
||||||
&[event_id("IMC")],
|
&["IMC"],
|
||||||
);
|
);
|
||||||
|
|
||||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||||
@ -909,7 +909,7 @@ mod tests {
|
|||||||
Some(alice().as_str()),
|
Some(alice().as_str()),
|
||||||
member_content_ban(),
|
member_content_ban(),
|
||||||
&[],
|
&[],
|
||||||
&[event_id("IMC")],
|
&["IMC"],
|
||||||
);
|
);
|
||||||
|
|
||||||
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
let fetch_state = |ty, key| auth_events.get(&(ty, key)).cloned();
|
||||||
|
@ -17,7 +17,7 @@ use ruma_events::{
|
|||||||
},
|
},
|
||||||
EventType,
|
EventType,
|
||||||
};
|
};
|
||||||
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
|
use ruma_identifiers::{event_id, room_id, user_id, EventId, RoomId, RoomVersionId, UserId};
|
||||||
use serde_json::{
|
use serde_json::{
|
||||||
json,
|
json,
|
||||||
value::{to_raw_value as to_raw_json_value, RawValue as RawJsonValue},
|
value::{to_raw_value as to_raw_json_value, RawValue as RawJsonValue},
|
||||||
@ -181,10 +181,10 @@ pub fn do_check(
|
|||||||
expected_state.insert(key, node);
|
expected_state.insert(key, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
let start_state = state_at_event.get(&event_id("$START:foo")).unwrap();
|
let start_state = state_at_event.get(&event_id!("$START:foo")).unwrap();
|
||||||
|
|
||||||
let end_state = state_at_event
|
let end_state = state_at_event
|
||||||
.get(&event_id("$END:foo"))
|
.get(&event_id!("$END:foo"))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(k, v)| {
|
.filter(|(k, v)| {
|
||||||
@ -341,23 +341,27 @@ pub fn event_id(id: &str) -> EventId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn alice() -> UserId {
|
pub fn alice() -> UserId {
|
||||||
UserId::try_from("@alice:foo").unwrap()
|
user_id!("@alice:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bob() -> UserId {
|
pub fn bob() -> UserId {
|
||||||
UserId::try_from("@bob:foo").unwrap()
|
user_id!("@bob:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn charlie() -> UserId {
|
pub fn charlie() -> UserId {
|
||||||
UserId::try_from("@charlie:foo").unwrap()
|
user_id!("@charlie:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ella() -> UserId {
|
pub fn ella() -> UserId {
|
||||||
UserId::try_from("@ella:foo").unwrap()
|
user_id!("@ella:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn zara() -> UserId {
|
pub fn zara() -> UserId {
|
||||||
UserId::try_from("@zara:foo").unwrap()
|
user_id!("@zara:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn room_id() -> RoomId {
|
pub fn room_id() -> RoomId {
|
||||||
RoomId::try_from("!test:foo").unwrap()
|
room_id!("!test:foo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn member_content_ban() -> Box<RawJsonValue> {
|
pub fn member_content_ban() -> Box<RawJsonValue> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user