Skip to content

Commit

Permalink
task: move the EventFactory to the matrix-sdk-test crate
Browse files Browse the repository at this point in the history
This makes it available to the crypto crate, by lowering it into the
local dependency tree.
  • Loading branch information
bnjbvr committed Nov 20, 2024
1 parent 2df922e commit 378776e
Show file tree
Hide file tree
Showing 30 changed files with 82 additions and 95 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions benchmarks/benches/room_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ use std::{sync::Arc, time::Duration};

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use matrix_sdk::{
config::SyncSettings,
test_utils::{events::EventFactory, logged_in_client_with_server},
utils::IntoRawStateEventContent,
config::SyncSettings, test_utils::logged_in_client_with_server, utils::IntoRawStateEventContent,
};
use matrix_sdk_base::{
store::StoreConfig, BaseClient, RoomInfo, RoomState, SessionMeta, StateChanges, StateStore,
};
use matrix_sdk_sqlite::SqliteStateStore;
use matrix_sdk_test::{EventBuilder, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder};
use matrix_sdk_test::{
event_factory::EventFactory, EventBuilder, JoinedRoomBuilder, StateTestEvent,
SyncResponseBuilder,
};
use matrix_sdk_ui::{timeline::TimelineFocus, Timeline};
use ruma::{
api::client::membership::get_member_events,
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,14 @@ impl ReactionsByKeyBySender {
mod tests {
use assert_matches::assert_matches;
use assert_matches2::assert_let;
use matrix_sdk::test_utils::{events::EventFactory, logged_in_client};
use matrix_sdk::test_utils::logged_in_client;
use matrix_sdk_base::{
deserialized_responses::SyncTimelineEvent, latest_event::LatestEvent, sliding_sync::http,
MinimalStateEvent, OriginalMinimalStateEvent,
};
use matrix_sdk_test::{async_test, sync_state_event, sync_timeline_event};
use matrix_sdk_test::{
async_test, event_factory::EventFactory, sync_state_event, sync_timeline_event,
};
use ruma::{
event_id,
events::{
Expand Down
7 changes: 2 additions & 5 deletions crates/matrix-sdk-ui/src/timeline/tests/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ use std::sync::Arc;

use assert_matches::assert_matches;
use eyeball_im::VectorDiff;
use matrix_sdk::{
assert_next_matches_with_timeout, send_queue::RoomSendQueueUpdate,
test_utils::events::EventFactory,
};
use matrix_sdk::{assert_next_matches_with_timeout, send_queue::RoomSendQueueUpdate};
use matrix_sdk_base::store::QueueWedgeError;
use matrix_sdk_test::{async_test, ALICE, BOB};
use matrix_sdk_test::{async_test, event_factory::EventFactory, ALICE, BOB};
use ruma::{
event_id,
events::{room::message::RoomMessageEventContent, AnyMessageLikeEventContent},
Expand Down
5 changes: 3 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ use matrix_sdk::{
event_cache::paginator::{PaginableRoom, PaginatorError},
room::{EventWithContextResponse, Messages, MessagesOptions},
send_queue::RoomSendQueueUpdate,
test_utils::events::EventFactory,
BoxFuture,
};
use matrix_sdk_base::{latest_event::LatestEvent, RoomInfo, RoomState};
use matrix_sdk_test::{EventBuilder, ALICE, BOB, DEFAULT_TEST_ROOM_ID};
use matrix_sdk_test::{
event_factory::EventFactory, EventBuilder, ALICE, BOB, DEFAULT_TEST_ROOM_ID,
};
use ruma::{
event_id,
events::{
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/tests/reactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use assert_matches2::{assert_let, assert_matches};
use eyeball_im::VectorDiff;
use futures_core::Stream;
use futures_util::{FutureExt as _, StreamExt as _};
use matrix_sdk::{deserialized_responses::SyncTimelineEvent, test_utils::events::EventFactory};
use matrix_sdk_test::{async_test, sync_timeline_event, ALICE, BOB};
use matrix_sdk::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::{async_test, event_factory::EventFactory, sync_timeline_event, ALICE, BOB};
use ruma::{
event_id, events::AnyMessageLikeEventContent, server_name, uint, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId,
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk-ui/src/timeline/tests/read_receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
use std::sync::Arc;

use eyeball_im::VectorDiff;
use matrix_sdk::test_utils::events::EventFactory;
use matrix_sdk_test::{async_test, ALICE, BOB, CAROL};
use matrix_sdk_test::{async_test, event_factory::EventFactory, ALICE, BOB, CAROL};
use ruma::{
event_id,
events::{
Expand Down
10 changes: 4 additions & 6 deletions crates/matrix-sdk-ui/tests/integration/timeline/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::StreamExt;
use matrix_sdk::{
assert_next_matches_with_timeout,
config::SyncSettings,
executor::spawn,
ruma::MilliSecondsSinceUnixEpoch,
test_utils::{events::EventFactory, logged_in_client_with_server},
assert_next_matches_with_timeout, config::SyncSettings, executor::spawn,
ruma::MilliSecondsSinceUnixEpoch, test_utils::logged_in_client_with_server,
};
use matrix_sdk_test::{
async_test, mocks::mock_encryption_state, JoinedRoomBuilder, SyncResponseBuilder,
async_test, event_factory::EventFactory, mocks::mock_encryption_state, JoinedRoomBuilder,
SyncResponseBuilder,
};
use matrix_sdk_ui::timeline::{EventSendState, RoomExt, TimelineItemContent};
use ruma::{
Expand Down
7 changes: 3 additions & 4 deletions crates/matrix-sdk-ui/tests/integration/timeline/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::{FutureExt, StreamExt};
use matrix_sdk::{
config::SyncSettings,
room::edit::EditedContent,
test_utils::{events::EventFactory, logged_in_client_with_server},
config::SyncSettings, room::edit::EditedContent, test_utils::logged_in_client_with_server,
Client,
};
use matrix_sdk_test::{
async_test, mocks::mock_encryption_state, JoinedRoomBuilder, SyncResponseBuilder, ALICE, BOB,
async_test, event_factory::EventFactory, mocks::mock_encryption_state, JoinedRoomBuilder,
SyncResponseBuilder, ALICE, BOB,
};
use matrix_sdk_ui::{
timeline::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::StreamExt;
use matrix_sdk::{
assert_next_matches_with_timeout,
config::SyncSettings,
test_utils::{events::EventFactory, logged_in_client_with_server},
assert_next_matches_with_timeout, config::SyncSettings,
test_utils::logged_in_client_with_server,
};
use matrix_sdk_test::{
async_test, mocks::mock_encryption_state, JoinedRoomBuilder, SyncResponseBuilder, ALICE, BOB,
async_test, event_factory::EventFactory, mocks::mock_encryption_state, JoinedRoomBuilder,
SyncResponseBuilder, ALICE, BOB,
};
use matrix_sdk_ui::{timeline::TimelineFocus, Timeline};
use ruma::{event_id, events::room::message::RoomMessageEventContent, room_id};
Expand Down
6 changes: 2 additions & 4 deletions crates/matrix-sdk-ui/tests/integration/timeline/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::{FutureExt, StreamExt};
use matrix_sdk::{
assert_let_timeout,
attachment::AttachmentConfig,
test_utils::{events::EventFactory, mocks::MatrixMockServer},
assert_let_timeout, attachment::AttachmentConfig, test_utils::mocks::MatrixMockServer,
};
use matrix_sdk_test::{async_test, JoinedRoomBuilder, ALICE};
use matrix_sdk_test::{async_test, event_factory::EventFactory, JoinedRoomBuilder, ALICE};
use matrix_sdk_ui::timeline::{EventSendState, RoomExt, TimelineItemContent};
use ruma::{
event_id,
Expand Down
5 changes: 2 additions & 3 deletions crates/matrix-sdk-ui/tests/integration/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::StreamExt;
use matrix_sdk::{
assert_let_timeout,
config::SyncSettings,
test_utils::{events::EventFactory, logged_in_client_with_server},
assert_let_timeout, config::SyncSettings, test_utils::logged_in_client_with_server,
};
use matrix_sdk_test::{
async_test,
event_factory::EventFactory,
mocks::{mock_encryption_state, mock_redaction},
sync_timeline_event, JoinedRoomBuilder, RoomAccountDataTestEvent, StateTestEvent,
SyncResponseBuilder, BOB,
Expand Down
12 changes: 6 additions & 6 deletions crates/matrix-sdk-ui/tests/integration/timeline/pinned_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use std::time::Duration;
use assert_matches::assert_matches;
use eyeball_im::VectorDiff;
use matrix_sdk::{
assert_next_matches_with_timeout,
config::SyncSettings,
sync::SyncResponse,
test_utils::{events::EventFactory, logged_in_client_with_server},
Client,
assert_next_matches_with_timeout, config::SyncSettings, sync::SyncResponse,
test_utils::logged_in_client_with_server, Client,
};
use matrix_sdk_base::deserialized_responses::TimelineEvent;
use matrix_sdk_test::{async_test, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder, BOB};
use matrix_sdk_test::{
async_test, event_factory::EventFactory, JoinedRoomBuilder, StateTestEvent,
SyncResponseBuilder, BOB,
};
use matrix_sdk_ui::{
timeline::{RoomExt, TimelineFocus, TimelineItemContent},
Timeline,
Expand Down
6 changes: 2 additions & 4 deletions crates/matrix-sdk-ui/tests/integration/timeline/reactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ use std::{sync::Mutex, time::Duration};
use assert_matches2::{assert_let, assert_matches};
use eyeball_im::VectorDiff;
use futures_util::{FutureExt as _, StreamExt as _};
use matrix_sdk::{
assert_next_matches_with_timeout,
test_utils::{events::EventFactory, logged_in_client_with_server},
};
use matrix_sdk::{assert_next_matches_with_timeout, test_utils::logged_in_client_with_server};
use matrix_sdk_test::{
async_test,
event_factory::EventFactory,
mocks::{mock_encryption_state, mock_redaction},
JoinedRoomBuilder, SyncResponseBuilder, ALICE,
};
Expand Down
9 changes: 3 additions & 6 deletions crates/matrix-sdk-ui/tests/integration/timeline/replies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ use assert_matches::assert_matches;
use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::StreamExt;
use matrix_sdk::{
config::SyncSettings,
test_utils::{events::EventFactory, logged_in_client_with_server},
};
use matrix_sdk::{config::SyncSettings, test_utils::logged_in_client_with_server};
use matrix_sdk_base::timeout::timeout;
use matrix_sdk_test::{
async_test, mocks::mock_encryption_state, EventBuilder, JoinedRoomBuilder, SyncResponseBuilder,
ALICE, BOB, CAROL,
async_test, event_factory::EventFactory, mocks::mock_encryption_state, EventBuilder,
JoinedRoomBuilder, SyncResponseBuilder, ALICE, BOB, CAROL,
};
use matrix_sdk_ui::timeline::{
Error as TimelineError, EventSendState, RoomExt, TimelineDetails, TimelineItemContent,
Expand Down
9 changes: 3 additions & 6 deletions crates/matrix-sdk-ui/tests/integration/timeline/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ use assert_matches::assert_matches;
use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::{pin_mut, StreamExt};
use matrix_sdk::{
config::SyncSettings,
test_utils::{events::EventFactory, logged_in_client_with_server},
};
use matrix_sdk::{config::SyncSettings, test_utils::logged_in_client_with_server};
use matrix_sdk_test::{
async_test, mocks::mock_encryption_state, sync_timeline_event, EventBuilder,
GlobalAccountDataTestEvent, JoinedRoomBuilder, SyncResponseBuilder, ALICE, BOB,
async_test, event_factory::EventFactory, mocks::mock_encryption_state, sync_timeline_event,
EventBuilder, GlobalAccountDataTestEvent, JoinedRoomBuilder, SyncResponseBuilder, ALICE, BOB,
};
use matrix_sdk_ui::timeline::{RoomExt, TimelineDetails, TimelineItemContent};
use ruma::{
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk/src/event_cache/deduplicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ pub enum Decoration<I> {
mod tests {
use assert_matches2::{assert_let, assert_matches};
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{owned_event_id, user_id, EventId};

use super::*;
use crate::test_utils::events::EventFactory;

fn sync_timeline_event(event_id: &EventId) -> SyncTimelineEvent {
EventFactory::new()
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/event_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ mod tests {
use assert_matches::assert_matches;
use futures_util::FutureExt as _;
use matrix_sdk_base::sync::{JoinedRoomUpdate, RoomUpdates, Timeline};
use matrix_sdk_test::async_test;
use matrix_sdk_test::{async_test, event_factory::EventFactory};
use ruma::{event_id, room_id, serde::Raw, user_id};
use serde_json::json;

use super::{EventCacheError, RoomEventCacheUpdate};
use crate::test_utils::{assert_event_matches_msg, events::EventFactory, logged_in_client};
use crate::test_utils::{assert_event_matches_msg, logged_in_client};

#[async_test]
async fn test_must_explicitly_subscribe() {
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/event_cache/paginator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ mod tests {
use futures_core::Future;
use futures_util::FutureExt as _;
use matrix_sdk_base::deserialized_responses::TimelineEvent;
use matrix_sdk_test::async_test;
use matrix_sdk_test::{async_test, event_factory::EventFactory};
use once_cell::sync::Lazy;
use ruma::{api::Direction, event_id, room_id, uint, user_id, EventId, RoomId, UInt, UserId};
use tokio::{
Expand All @@ -572,7 +572,7 @@ mod tests {
use crate::{
event_cache::paginator::Paginator,
room::{EventWithContextResponse, Messages, MessagesOptions},
test_utils::{assert_event_matches_msg, events::EventFactory},
test_utils::assert_event_matches_msg,
};

#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk/src/event_cache/room/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ impl RoomEvents {
#[cfg(test)]
mod tests {
use assert_matches2::assert_let;
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{user_id, EventId, OwnedEventId};

use super::*;
use crate::test_utils::events::EventFactory;

macro_rules! assert_events_eq {
( $events_iterator:expr, [ $( ( $event_id:ident at ( $chunk_identifier:literal, $index:literal ) ) ),* $(,)? ] ) => {
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/event_cache/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,14 +559,14 @@ impl RoomEventCacheState {
#[cfg(test)]
mod tests {
use matrix_sdk_common::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::async_test;
use matrix_sdk_test::{async_test, event_factory::EventFactory};
use ruma::{
event_id,
events::{relation::RelationType, room::message::RoomMessageEventContentWithoutRelation},
room_id, user_id, RoomId,
};

use crate::test_utils::{events::EventFactory, logged_in_client};
use crate::test_utils::logged_in_client;

#[async_test]
async fn test_event_with_redaction_relation() {
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk/src/room/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ mod tests {

use assert_matches2::{assert_let, assert_matches};
use matrix_sdk_base::deserialized_responses::SyncTimelineEvent;
use matrix_sdk_test::async_test;
use matrix_sdk_test::{async_test, event_factory::EventFactory};
use ruma::{
event_id,
events::{
Expand All @@ -367,7 +367,7 @@ mod tests {
use serde_json::json;

use super::{make_edit_event, EditError, EventSource};
use crate::{room::edit::EditedContent, test_utils::events::EventFactory};
use crate::room::edit::EditedContent;

#[derive(Default)]
struct TestEventCache {
Expand Down
2 changes: 0 additions & 2 deletions crates/matrix-sdk/src/test_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use ruma::{
};
use url::Url;

pub mod events;

pub mod client;
#[cfg(not(target_arch = "wasm32"))]
pub mod mocks;
Expand Down
5 changes: 3 additions & 2 deletions crates/matrix-sdk/tests/integration/event_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use matrix_sdk::{
paginator::PaginatorState, BackPaginationOutcome, EventCacheError, RoomEventCacheUpdate,
TimelineHasBeenResetWhilePaginating,
},
test_utils::{assert_event_matches_msg, events::EventFactory, logged_in_client_with_server},
test_utils::{assert_event_matches_msg, logged_in_client_with_server},
};
use matrix_sdk_test::{
async_test, GlobalAccountDataTestEvent, JoinedRoomBuilder, SyncResponseBuilder,
async_test, event_factory::EventFactory, GlobalAccountDataTestEvent, JoinedRoomBuilder,
SyncResponseBuilder,
};
use ruma::{event_id, events::AnyTimelineEvent, room_id, serde::Raw, user_id};
use serde_json::json;
Expand Down
11 changes: 4 additions & 7 deletions crates/matrix-sdk/tests/integration/room/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ use std::{iter, time::Duration};

use assert_matches2::{assert_let, assert_matches};
use js_int::uint;
use matrix_sdk::{
config::SyncSettings, room::RoomMember, test_utils::events::EventFactory, RoomDisplayName,
RoomMemberships,
};
use matrix_sdk::{config::SyncSettings, room::RoomMember, RoomDisplayName, RoomMemberships};
use matrix_sdk_test::{
async_test, bulk_room_members, sync_state_event, sync_timeline_event, test_json,
GlobalAccountDataTestEvent, JoinedRoomBuilder, LeftRoomBuilder, StateTestEvent,
SyncResponseBuilder, BOB, DEFAULT_TEST_ROOM_ID,
async_test, bulk_room_members, event_factory::EventFactory, sync_state_event,
sync_timeline_event, test_json, GlobalAccountDataTestEvent, JoinedRoomBuilder, LeftRoomBuilder,
StateTestEvent, SyncResponseBuilder, BOB, DEFAULT_TEST_ROOM_ID,
};
use ruma::{
event_id,
Expand Down
Loading

0 comments on commit 378776e

Please sign in to comment.