diff --git a/crates/matrix-sdk-ui/src/timeline/tests/basic.rs b/crates/matrix-sdk-ui/src/timeline/tests/basic.rs index 96ad773c0..ffc78c45f 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/basic.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/basic.rs @@ -16,7 +16,7 @@ use assert_matches::assert_matches; use eyeball_im::VectorDiff; use imbl::vector; use matrix_sdk_base::deserialized_responses::SyncTimelineEvent; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB, CAROL}; use ruma::{ assign, events::{ @@ -32,9 +32,9 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::{ - event_item::AnyOtherFullStateEventContent, tests::CAROL, MembershipChange, TimelineDetails, + event_item::AnyOtherFullStateEventContent, MembershipChange, TimelineDetails, TimelineItemContent, TimelineItemKind, VirtualTimelineItem, }; diff --git a/crates/matrix-sdk-ui/src/timeline/tests/echo.rs b/crates/matrix-sdk-ui/src/timeline/tests/echo.rs index 0b5c3a6db..38a57e0f8 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/echo.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/echo.rs @@ -17,14 +17,14 @@ use std::{io, sync::Arc}; use assert_matches::assert_matches; use eyeball_im::VectorDiff; use matrix_sdk::Error; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB}; use ruma::{ event_id, events::{room::message::RoomMessageEventContent, AnyMessageLikeEventContent}, }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::event_item::EventSendState; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/edit.rs b/crates/matrix-sdk-ui/src/timeline/tests/edit.rs index d51cdef20..5c1896476 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/edit.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/edit.rs @@ -14,7 +14,7 @@ use assert_matches::assert_matches; use eyeball_im::VectorDiff; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE}; use ruma::{ assign, events::{ @@ -27,7 +27,7 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE}; +use super::TestTimeline; use crate::timeline::TimelineItemContent; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/encryption.rs b/crates/matrix-sdk-ui/src/timeline/tests/encryption.rs index ac6f06307..f70248337 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/encryption.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/encryption.rs @@ -19,7 +19,7 @@ use std::{io::Cursor, iter}; use assert_matches::assert_matches; use eyeball_im::VectorDiff; use matrix_sdk::crypto::{decrypt_room_key_export, OlmMachine}; -use matrix_sdk_test::async_test; +use matrix_sdk_test::{async_test, BOB}; use ruma::{ assign, events::room::encrypted::{ @@ -30,7 +30,7 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, BOB}; +use super::TestTimeline; use crate::timeline::{EncryptedMessage, TimelineItemContent}; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/event_filter.rs b/crates/matrix-sdk-ui/src/timeline/tests/event_filter.rs index f73c938ff..efb7dd336 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/event_filter.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/event_filter.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use assert_matches::assert_matches; use eyeball_im::VectorDiff; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB}; use ruma::{ assign, events::{ @@ -34,7 +34,7 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::{inner::TimelineInnerSettings, TimelineItemContent}; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/invalid.rs b/crates/matrix-sdk-ui/src/timeline/tests/invalid.rs index 6f61f447f..029336149 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/invalid.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/invalid.rs @@ -14,7 +14,7 @@ use assert_matches::assert_matches; use eyeball_im::VectorDiff; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB}; use ruma::{ assign, events::{ @@ -26,7 +26,7 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::TimelineItemContent; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/mod.rs b/crates/matrix-sdk-ui/src/timeline/tests/mod.rs index f32b3f2b9..1fd26e21a 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/mod.rs @@ -23,8 +23,7 @@ use futures_core::Stream; use futures_util::{FutureExt, StreamExt}; use indexmap::IndexMap; use matrix_sdk::deserialized_responses::{SyncTimelineEvent, TimelineEvent}; -use matrix_sdk_test::{sync_timeline_event, EventBuilder}; -use once_cell::sync::Lazy; +use matrix_sdk_test::{sync_timeline_event, EventBuilder, ALICE}; use ruma::{ events::{ receipt::{Receipt, ReceiptThread, ReceiptType}, @@ -39,8 +38,8 @@ use ruma::{ push::{PushConditionRoomCtx, Ruleset}, room_id, serde::Raw, - server_name, uint, user_id, EventId, OwnedEventId, OwnedTransactionId, OwnedUserId, - RoomVersionId, TransactionId, UserId, + server_name, uint, EventId, OwnedEventId, OwnedTransactionId, OwnedUserId, RoomVersionId, + TransactionId, UserId, }; use super::{ @@ -65,10 +64,6 @@ mod read_receipts; mod redaction; mod virt; -static ALICE: Lazy<&UserId> = Lazy::new(|| user_id!("@alice:server.name")); -static BOB: Lazy<&UserId> = Lazy::new(|| user_id!("@bob:other.server")); -static CAROL: Lazy<&UserId> = Lazy::new(|| user_id!("@carol:other.server")); - struct TestTimeline { inner: TimelineInner, event_builder: EventBuilder, diff --git a/crates/matrix-sdk-ui/src/timeline/tests/polls.rs b/crates/matrix-sdk-ui/src/timeline/tests/polls.rs index d89cd0082..8aa045426 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/polls.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/polls.rs @@ -1,4 +1,4 @@ -use matrix_sdk_test::async_test; +use matrix_sdk_test::{async_test, ALICE, BOB}; use ruma::{ events::{ poll::{ @@ -15,9 +15,7 @@ use ruma::{ }; use crate::timeline::{ - polls::PollState, - tests::{TestTimeline, ALICE, BOB}, - EventTimelineItem, TimelineItemContent, + polls::PollState, tests::TestTimeline, EventTimelineItem, TimelineItemContent, }; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/reaction_group.rs b/crates/matrix-sdk-ui/src/timeline/tests/reaction_group.rs index 12ca5c17e..dd3b19a31 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/reaction_group.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/reaction_group.rs @@ -14,13 +14,10 @@ use assert_matches::assert_matches; use itertools::Itertools; +use matrix_sdk_test::{ALICE, BOB}; use ruma::{server_name, uint, user_id, EventId, MilliSecondsSinceUnixEpoch, OwnedUserId, UserId}; -use crate::timeline::{ - event_item::EventItemIdentifier, - tests::{ALICE, BOB}, - ReactionGroup, ReactionSenderData, -}; +use crate::timeline::{event_item::EventItemIdentifier, ReactionGroup, ReactionSenderData}; #[test] fn by_sender() { diff --git a/crates/matrix-sdk-ui/src/timeline/tests/reactions.rs b/crates/matrix-sdk-ui/src/timeline/tests/reactions.rs index e4bddde2e..d22d20d49 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/reactions.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/reactions.rs @@ -19,7 +19,7 @@ use eyeball_im::VectorDiff; use futures_core::Stream; use imbl::vector; use matrix_sdk_base::deserialized_responses::SyncTimelineEvent; -use matrix_sdk_test::async_test; +use matrix_sdk_test::{async_test, ALICE, BOB}; use ruma::{ events::{relation::Annotation, room::message::RoomMessageEventContent}, server_name, uint, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, TransactionId, @@ -30,7 +30,7 @@ use crate::timeline::{ event_item::EventItemIdentifier, inner::ReactionAction, reactions::ReactionToggleResult, - tests::{assert_event_is_updated, assert_no_more_updates, TestTimeline, ALICE, BOB}, + tests::{assert_event_is_updated, assert_no_more_updates, TestTimeline}, TimelineItem, }; diff --git a/crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs b/crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs index 43b06db6b..120dbe435 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs @@ -13,14 +13,14 @@ // limitations under the License. use eyeball_im::VectorDiff; -use matrix_sdk_test::async_test; +use matrix_sdk_test::{async_test, ALICE, BOB}; use ruma::events::{ receipt::{ReceiptThread, ReceiptType}, room::message::RoomMessageEventContent, }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::inner::TimelineInnerSettings; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/redaction.rs b/crates/matrix-sdk-ui/src/timeline/tests/redaction.rs index 07ab207ee..707d8c915 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/redaction.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/redaction.rs @@ -16,7 +16,7 @@ use assert_matches::assert_matches; use eyeball_im::VectorDiff; use imbl::vector; use matrix_sdk_base::deserialized_responses::SyncTimelineEvent; -use matrix_sdk_test::{async_test, sync_timeline_event}; +use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB}; use ruma::{ events::{ reaction::{ReactionEventContent, RedactedReactionEventContent}, @@ -34,7 +34,7 @@ use ruma::{ }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::{AnyOtherFullStateEventContent, TimelineDetails, TimelineItemContent}; #[async_test] diff --git a/crates/matrix-sdk-ui/src/timeline/tests/virt.rs b/crates/matrix-sdk-ui/src/timeline/tests/virt.rs index 2b00dd5f7..dd9f15326 100644 --- a/crates/matrix-sdk-ui/src/timeline/tests/virt.rs +++ b/crates/matrix-sdk-ui/src/timeline/tests/virt.rs @@ -15,14 +15,14 @@ use assert_matches::assert_matches; use chrono::{Datelike, Local, TimeZone}; use eyeball_im::VectorDiff; -use matrix_sdk_test::async_test; +use matrix_sdk_test::{async_test, ALICE, BOB}; use ruma::{ event_id, events::{room::message::RoomMessageEventContent, AnyMessageLikeEventContent}, }; use stream_assert::assert_next_matches; -use super::{TestTimeline, ALICE, BOB}; +use super::TestTimeline; use crate::timeline::{TimelineItemKind, VirtualTimelineItem}; #[async_test] diff --git a/testing/matrix-sdk-test/src/lib.rs b/testing/matrix-sdk-test/src/lib.rs index 4df0fbdc1..3ef656172 100644 --- a/testing/matrix-sdk-test/src/lib.rs +++ b/testing/matrix-sdk-test/src/lib.rs @@ -1,6 +1,10 @@ use http::Response; pub use matrix_sdk_test_macros::async_test; -use ruma::api::{client::sync::sync_events::v3::Response as SyncResponse, IncomingResponse}; +use once_cell::sync::Lazy; +use ruma::{ + api::{client::sync::sync_events::v3::Response as SyncResponse, IncomingResponse}, + user_id, UserId, +}; use serde_json::Value as JsonValue; /// Create a `Raw` from arbitrary JSON. @@ -29,6 +33,10 @@ pub use self::{ }, }; +pub static ALICE: Lazy<&UserId> = Lazy::new(|| user_id!("@alice:server.name")); +pub static BOB: Lazy<&UserId> = Lazy::new(|| user_id!("@bob:other.server")); +pub static CAROL: Lazy<&UserId> = Lazy::new(|| user_id!("@carol:other.server")); + /// Embedded sync response files pub enum SyncResponseFile { All,