2021-06-30 23:34:34 +00:00
|
|
|
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
|
|
|
#![feature(async_closure)]
|
|
|
|
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
|
|
|
|
|
|
|
mod async_tests;
|
|
|
|
mod testutils;
|
|
|
|
use testutils::*;
|
|
|
|
|
|
|
|
use futures_util::future;
|
|
|
|
use colored::*;
|
|
|
|
|
|
|
|
use riven::consts::*;
|
|
|
|
use riven::models::summoner_v4::Summoner;
|
|
|
|
|
|
|
|
const REGION: Region = Region::KR;
|
|
|
|
|
|
|
|
|
|
|
|
async_tests!{
|
|
|
|
my_runner {
|
|
|
|
league_summoner_bulk_test: async {
|
|
|
|
|
|
|
|
let leagues = (1..10)
|
|
|
|
.map(async move |i| {
|
|
|
|
let leaguelist = RIOT_API.league_v4().get_league_entries(REGION,
|
|
|
|
QueueType::RANKED_SOLO_5x5, Tier::GOLD, Division::III, Some(i));
|
|
|
|
let leaguelist = leaguelist.await
|
|
|
|
.map_err(|e| e.to_string())?
|
|
|
|
.ok_or("Failed to get challenger league".to_owned())?;
|
|
|
|
|
|
|
|
println!("League list {}: {} items.", i, leaguelist.len());
|
|
|
|
|
|
|
|
let summoners = leaguelist
|
|
|
|
.iter()
|
|
|
|
.map(async move |leagueentry| {
|
|
|
|
let summonerfuture = RIOT_API.summoner_v4().get_by_summoner_id(
|
|
|
|
REGION, &leagueentry.summoner_id);
|
|
|
|
summonerfuture.await
|
|
|
|
.map_err(|e| e.to_string())?
|
2024-01-04 17:26:16 +00:00
|
|
|
.ok_or(format!("Failed to find summoner_id {}.",
|
2021-06-30 23:34:34 +00:00
|
|
|
leagueentry.summoner_id))
|
|
|
|
});
|
|
|
|
future::join_all(summoners).await
|
|
|
|
.into_iter()
|
|
|
|
// I'm not sure where this result goes.
|
|
|
|
.collect::<Result<Vec<Summoner>, String>>()
|
|
|
|
});
|
|
|
|
|
|
|
|
let all_summoners = future::join_all(leagues).await
|
|
|
|
.into_iter()
|
|
|
|
.flat_map(|league| league)
|
|
|
|
.flat_map(|summoner| summoner);
|
|
|
|
|
|
|
|
for (i, summoner) in all_summoners.enumerate() {
|
|
|
|
println!("{}: {}", i + 1, summoner.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|