2023-05-20 21:04:03 +02:00
|
|
|
use std::sync::Mutex;
|
2023-05-20 12:22:54 +02:00
|
|
|
|
2023-05-20 21:04:03 +02:00
|
|
|
use chorus::{
|
|
|
|
api::{AuthUsername, LoginSchema, User},
|
|
|
|
instance::Instance,
|
|
|
|
limit::LimitedRequester,
|
|
|
|
URLBundle,
|
|
|
|
};
|
|
|
|
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
static ref INSTANCE: Mutex<Instance> =
|
|
|
|
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
|
|
|
Mutex::new(
|
|
|
|
Instance::new(
|
|
|
|
URLBundle::new(
|
|
|
|
"http://localhost:3001/api".to_string(),
|
|
|
|
"ws://localhost:3001".to_string(),
|
|
|
|
"http://localhost:3001".to_string(),
|
|
|
|
),
|
|
|
|
LimitedRequester::new().await,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap(),
|
|
|
|
)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TestBundle<'a> {
|
2023-05-20 12:22:54 +02:00
|
|
|
urls: URLBundle,
|
2023-05-20 21:04:03 +02:00
|
|
|
user: User<'a>,
|
2023-05-20 12:22:54 +02:00
|
|
|
}
|
|
|
|
|
2023-05-20 21:04:03 +02:00
|
|
|
async fn setup<'a>() -> TestBundle<'a> {
|
2023-05-20 12:22:54 +02:00
|
|
|
let urls = URLBundle::new(
|
|
|
|
"http://localhost:3001/api".to_string(),
|
|
|
|
"ws://localhost:3001".to_string(),
|
|
|
|
"http://localhost:3001".to_string(),
|
|
|
|
);
|
|
|
|
let requester = LimitedRequester::new().await;
|
2023-05-20 21:04:03 +02:00
|
|
|
let mut instance = Instance::new(urls.clone(), requester).await.unwrap();
|
|
|
|
// Requires the existance of the below user.
|
|
|
|
let login_schema: LoginSchema = LoginSchema::new(
|
|
|
|
AuthUsername::new("user@test.xyz".to_string()).unwrap(),
|
|
|
|
"transrights".to_string(),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
let user = instance.login_account(&login_schema).await.unwrap();
|
2023-05-20 12:22:54 +02:00
|
|
|
|
2023-05-20 21:04:03 +02:00
|
|
|
TestBundle {
|
|
|
|
urls: urls,
|
|
|
|
user: user,
|
|
|
|
}
|
2023-05-20 12:22:54 +02:00
|
|
|
}
|