Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement EventCacheStoreLock::lock() with poison error, and ::lock_unchecked #4285

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh, this is super ugly, and those methods I wanted to see go away with the new MatrixMockServer and MockClientBuilder; any chance you can reuse MockClientBuilder instead?

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
}