2023-03-08 21:49:53 +00:00
|
|
|
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
|
|
|
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
|
|
|
|
|
|
|
mod async_tests;
|
|
|
|
mod testutils;
|
|
|
|
use testutils::*;
|
|
|
|
|
|
|
|
use colored::*;
|
|
|
|
|
|
|
|
use riven::consts::*;
|
|
|
|
|
|
|
|
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
|
|
|
|
|
|
|
static TFT_MATCHES: &[&str] = &[
|
|
|
|
"EUW1_6307427444", // https://github.com/MingweiSamuel/Riven/issues/50
|
|
|
|
"EUW1_6307262798",
|
|
|
|
];
|
|
|
|
|
|
|
|
async_tests! {
|
|
|
|
my_runner {
|
|
|
|
tftmatchv1_get_list: async {
|
|
|
|
tft_match_v1_get(ROUTE.to_regional(), TFT_MATCHES).await
|
|
|
|
},
|
|
|
|
|
|
|
|
// // Don't have acecess to tft-status-v1.
|
|
|
|
// tftstatusv1_getplatformdata: async {
|
|
|
|
// let p = RIOT_API.tft_status_v1().get_platform_data(ROUTE);
|
|
|
|
// let _s = p.await.map_err(|e| e.to_string())?;
|
|
|
|
// Ok(())
|
|
|
|
// },
|
|
|
|
tftleaguev1_getchallengerleague: async {
|
|
|
|
let p = RIOT_API.tft_league_v1().get_challenger_league(ROUTE);
|
|
|
|
let l = p.await.map_err(|e| e.to_string())?;
|
|
|
|
rassert!(l.entries.len() > 10, "Expected a few challenger players, got: {}.", l.entries.len());
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
tftmatchv1_getmatch: async {
|
|
|
|
let p = RIOT_API.tft_match_v1().get_match(ROUTE.to_regional(), "EUW1_4568680990");
|
|
|
|
let _m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT match.".to_owned())?;
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
tftsummonerv1_getbyname: async {
|
|
|
|
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "相当猥琐");
|
|
|
|
let _s = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT summoner.".to_owned())?;
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
tftsummonerv1_getbyname_none: async {
|
|
|
|
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "this summoner does not exist");
|
|
|
|
rassert!(p.await.map_err(|e| e.to_string())?.is_none());
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
// Get top rated player, get some of their matches.
|
|
|
|
tft_combo: async {
|
|
|
|
let top_players = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
|
|
|
let top_players = top_players.await.map_err(|e| e.to_string())?;
|
2023-05-10 18:27:57 +00:00
|
|
|
rassert!(!top_players.is_empty());
|
2023-03-08 21:49:53 +00:00
|
|
|
let top_player_entry = &top_players[0];
|
2023-05-10 18:27:57 +00:00
|
|
|
let top_player = RIOT_API.tft_summoner_v1().get_by_summoner_id(ROUTE, &top_player_entry.summoner_id);
|
2023-03-08 21:49:53 +00:00
|
|
|
let top_player = top_player.await.map_err(|e| e.to_string())?;
|
|
|
|
println!("Top player is {} with `puuid` {}.", top_player.name, top_player.puuid);
|
|
|
|
let match_ids = RIOT_API.tft_match_v1().get_match_ids_by_puuid(
|
2023-05-10 18:27:57 +00:00
|
|
|
ROUTE.to_regional(), &top_player.puuid, Some(10), None, None, None);
|
2023-03-08 21:49:53 +00:00
|
|
|
let match_ids = match_ids.await.map_err(|e| e.to_string())?;
|
|
|
|
tft_match_v1_get(ROUTE.to_regional(), &*match_ids).await?;
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|