use ig_client::prelude::*;
use tokio::runtime::Runtime;
use tracing::info;
pub fn create_test_client() -> Client {
Client::default()
}
pub fn login_with_account_switch() -> Session {
setup_logger();
let rt = Runtime::new().expect("Failed to create runtime");
rt.block_on(async {
login_with_account_switch_async()
.await
.expect("Failed to login")
})
}
pub async fn login_with_account_switch_async() -> Result<Session, String> {
setup_logger();
let http_client = HttpClient::default();
match http_client.get_session().await {
Ok(session) => {
info!("Logged in with account: {}", session.account_id);
Ok(session)
}
Err(e) => Err(format!("Failed to login: {e:?}")),
}
}