2021-12-08 09:33:22 +00:00
|
|
|
pub mod editor;
|
|
|
|
pub mod event_builder;
|
|
|
|
pub mod helper;
|
2021-07-16 15:18:12 +00:00
|
|
|
|
2021-09-04 08:12:48 +00:00
|
|
|
use crate::helper::*;
|
2021-12-05 08:39:41 +00:00
|
|
|
use backend_service::configuration::{get_client_server_configuration, ClientServerConfiguration};
|
2021-09-05 05:50:23 +00:00
|
|
|
use flowy_sdk::{FlowySDK, FlowySDKConfig};
|
2021-09-04 08:53:58 +00:00
|
|
|
use flowy_user::entities::UserProfile;
|
2021-11-19 06:38:11 +00:00
|
|
|
use lib_infra::uuid;
|
2021-07-06 06:14:47 +00:00
|
|
|
|
|
|
|
pub mod prelude {
|
2021-12-08 09:33:22 +00:00
|
|
|
pub use crate::{event_builder::*, helper::*, *};
|
2021-11-19 06:38:11 +00:00
|
|
|
pub use lib_dispatch::prelude::*;
|
2021-07-06 06:14:47 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 07:12:53 +00:00
|
|
|
#[derive(Clone)]
|
2021-12-08 09:33:22 +00:00
|
|
|
pub struct FlowySDKTest(pub FlowySDK);
|
|
|
|
|
|
|
|
impl std::ops::Deref for FlowySDKTest {
|
|
|
|
type Target = FlowySDK;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target { &self.0 }
|
2021-09-04 07:12:53 +00:00
|
|
|
}
|
|
|
|
|
2021-12-08 09:33:22 +00:00
|
|
|
impl FlowySDKTest {
|
2021-09-04 08:12:48 +00:00
|
|
|
pub fn setup() -> Self {
|
2021-12-05 08:39:41 +00:00
|
|
|
let server_config = get_client_server_configuration().unwrap();
|
2021-12-08 09:33:22 +00:00
|
|
|
let sdk = Self::setup_with(server_config);
|
|
|
|
std::mem::forget(sdk.dispatcher());
|
|
|
|
sdk
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn setup_with(server_config: ClientServerConfiguration) -> Self {
|
|
|
|
let config = FlowySDKConfig::new(&root_dir(), server_config, &uuid()).log_filter("debug");
|
|
|
|
let sdk = FlowySDK::new(config);
|
|
|
|
Self(sdk)
|
2021-09-28 07:29:29 +00:00
|
|
|
}
|
2021-09-27 15:23:23 +00:00
|
|
|
|
2021-09-28 07:29:29 +00:00
|
|
|
pub async fn sign_up(&self) -> SignUpContext {
|
2021-12-08 09:33:22 +00:00
|
|
|
let context = async_sign_up(self.0.dispatcher()).await;
|
2021-09-28 07:29:29 +00:00
|
|
|
context
|
2021-09-04 07:12:53 +00:00
|
|
|
}
|
|
|
|
|
2021-09-28 07:29:29 +00:00
|
|
|
pub async fn init_user(&self) -> UserProfile {
|
2021-12-08 09:33:22 +00:00
|
|
|
let context = async_sign_up(self.0.dispatcher()).await;
|
2021-09-28 07:29:29 +00:00
|
|
|
context.user_profile
|
|
|
|
}
|
2021-07-06 06:14:47 +00:00
|
|
|
}
|