2019-11-07 20:45:13 +00:00
|
|
|
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
|
|
|
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
2019-10-30 20:24:07 +00:00
|
|
|
|
|
|
|
mod async_tests;
|
2019-10-31 05:52:00 +00:00
|
|
|
mod testutils;
|
|
|
|
use testutils::*;
|
2019-10-30 20:24:07 +00:00
|
|
|
|
|
|
|
use colored::*;
|
|
|
|
|
|
|
|
use riven::consts::*;
|
2019-11-03 18:48:45 +00:00
|
|
|
use riven::models::summoner_v4::*;
|
2019-10-30 20:24:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
fn validate_lugnutsk(s: Summoner, tag: &str) -> Result<(), String> {
|
|
|
|
rassert_eq!("LugnutsK", s.name,
|
|
|
|
"LugnutsK name didn't match {}.", tag);
|
|
|
|
rassert_eq!(ids::SUMMONER_ID_LUGNUTSK, s.id,
|
|
|
|
"LugnutsK summonerId didn't match {}.", tag);
|
|
|
|
rassert_eq!(ids::ACCOUNT_ID_LUGNUTSK, s.account_id,
|
|
|
|
"LugnutsK accountId didn't match {}.", tag);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async_tests!{
|
|
|
|
my_runner {
|
|
|
|
// Summoner tests.
|
|
|
|
summoner_double: async {
|
|
|
|
let l1p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lug nuts k");
|
|
|
|
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lugnuts k");
|
|
|
|
let l1 = l1p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l1".to_owned())?;
|
|
|
|
let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l2".to_owned())?;
|
|
|
|
validate_lugnutsk(l1, "l1")?;
|
|
|
|
validate_lugnutsk(l2, "l2")?;
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
champion_getrotation: async {
|
|
|
|
let p = RIOT_API.champion_v3().get_champion_info(Region::NA);
|
2019-11-08 00:06:01 +00:00
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
2019-10-30 20:24:07 +00:00
|
|
|
let new_len = d.free_champion_ids_for_new_players.len();
|
|
|
|
let free_len = d.free_champion_ids.len();
|
|
|
|
let level = d.max_new_player_level;
|
|
|
|
rassert!(new_len >= 10, "New len: {}", new_len);
|
|
|
|
rassert!(free_len >= 15, "Free len: {}", free_len);
|
|
|
|
rassert_eq!(10, level, "New player level: {}", level);
|
|
|
|
Ok(())
|
|
|
|
},
|
2019-10-31 05:52:00 +00:00
|
|
|
leagueexp_get: async {
|
2019-10-31 08:09:20 +00:00
|
|
|
let p = RIOT_API.league_exp_v4().get_league_entries(Region::NA, QueueType::RANKED_SOLO_5x5, Tier::CHALLENGER, Division::I, None);
|
2019-11-08 00:06:01 +00:00
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!d.is_empty(), "Challenger shouldn't be empty.");
|
|
|
|
Ok(())
|
|
|
|
},
|
2019-10-30 20:24:07 +00:00
|
|
|
match_get: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 3190191338);
|
2019-11-08 00:06:01 +00:00
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
// match_get_old: async {
|
|
|
|
// let p = RIOT_API.match_v4().get_match(Region::NA, 2632789562);
|
|
|
|
// let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
|
|
|
// Ok(())
|
|
|
|
// },
|
|
|
|
match_get_aram: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 2961635718);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
match_get_urf900: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 2963663381);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
2020-03-31 18:50:21 +00:00
|
|
|
// Commented out, requires special API key.
|
|
|
|
// // LOR
|
|
|
|
// lor_ranked_get_leaderboards: async {
|
|
|
|
// let future = RIOT_API.lor_ranked_v1().get_leaderboards(Region::AMERICAS);
|
|
|
|
// let _leaderboard = future.await.map_err(|e| e.to_string())?;
|
|
|
|
// Ok(())
|
|
|
|
// },
|
2019-10-30 20:24:07 +00:00
|
|
|
}
|
|
|
|
}
|