forked from mirror/Riven
1
0
Fork 0
Riven/tests/tests_kr.rs.ignored

61 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

2019-11-07 20:45:13 +00:00
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
#![feature(async_closure)]
2019-11-07 20:45:13 +00:00
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
mod async_tests;
mod testutils;
use testutils::*;
use futures_util::future;
use colored::*;
use riven::consts::*;
2019-11-03 18:48:45 +00:00
use riven::models::summoner_v4::Summoner;
const REGION: Region = Region::KR;
async_tests!{
my_runner {
league_summoner_bulk_test: async {
2019-11-03 22:36:30 +00:00
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())?
.ok_or(format!("Failed to get summoner_id {}.",
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(())
},
}
}