Skip to content

Commit

Permalink
test(base): Add logged_in_base_client_with_store_config.
Browse files Browse the repository at this point in the history
This patch adds a small `logged_in_base_client_with_store_config`
function similarly to `logged_in_base_client`, but… with… a store
config!
  • Loading branch information
Hywan committed Nov 18, 2024
1 parent 942e4da commit a862d9e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions crates/matrix-sdk-base/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,24 @@ use crate::{store::StoreConfig, BaseClient, SessionMeta};
/// Create a [`BaseClient`] with the given user id, if provided, or an hardcoded
/// one otherwise.
pub(crate) async fn logged_in_base_client(user_id: Option<&UserId>) -> BaseClient {
let client = BaseClient::with_store_config(StoreConfig::new(
"cross-process-store-locks-holder-name".to_owned(),
));
logged_in_base_client_with_store_config(
user_id,
StoreConfig::new("cross-process-store-locks-holder-name".to_owned()),
)
.await
}

/// Create a [`BaseClient`] with the given user id, if provided, or an hardcoded
/// one otherwise, and with a store config.
pub(crate) async fn logged_in_base_client_with_store_config(
user_id: Option<&UserId>,
store_config: StoreConfig,
) -> BaseClient {
let client = BaseClient::with_store_config(store_config);

let user_id =
user_id.map(|user_id| user_id.to_owned()).unwrap_or_else(|| owned_user_id!("@u:e.uk"));

client
.set_session_meta(
SessionMeta { user_id: user_id.to_owned(), device_id: "FOOBAR".into() },
Expand All @@ -36,5 +49,6 @@ pub(crate) async fn logged_in_base_client(user_id: Option<&UserId>) -> BaseClien
)
.await
.expect("set_session_meta failed!");

client
}

0 comments on commit a862d9e

Please sign in to comment.