mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-27 03:16:33 +00:00
Make tests usable with any api key
This commit is contained in:
parent
387bd25eca
commit
fb0030e754
2 changed files with 13 additions and 12 deletions
|
@ -14,13 +14,19 @@ async_tests!{
|
||||||
my_runner {
|
my_runner {
|
||||||
// Champion Mastery tests.
|
// Champion Mastery tests.
|
||||||
championmastery_getscore_ma5tery: async {
|
championmastery_getscore_ma5tery: async {
|
||||||
let p = RIOT_API.champion_mastery_v4().get_champion_mastery_score(Region::EUW, ids::SUMMONER_ID_MA5TERY);
|
let sum = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, "ma5tery");
|
||||||
|
let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
|
||||||
|
|
||||||
|
let p = RIOT_API.champion_mastery_v4().get_champion_mastery_score(Region::EUW, &*sum.id);
|
||||||
let s = p.await.map_err(|e| e.to_string())?;
|
let s = p.await.map_err(|e| e.to_string())?;
|
||||||
rassert!(969 <= s && s <= 1000, "Unexpected ma5tery score: {}.", s);
|
rassert!(969 <= s && s <= 1000, "Unexpected ma5tery score: {}.", s);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
championmastery_getall_ma5tery: async {
|
championmastery_getall_ma5tery: async {
|
||||||
let p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(Region::EUW, ids::SUMMONER_ID_MA5TERY);
|
let sum = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, "ma5tery");
|
||||||
|
let sum = sum.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?;
|
||||||
|
|
||||||
|
let p = RIOT_API.champion_mastery_v4().get_all_champion_masteries(Region::EUW, &*sum.id);
|
||||||
let s = p.await.map_err(|e| e.to_string())?;
|
let s = p.await.map_err(|e| e.to_string())?;
|
||||||
rassert!(s.len() >= 142, "Expected masteries: {}.", s.len());
|
rassert!(s.len() >= 142, "Expected masteries: {}.", s.len());
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -10,14 +10,10 @@ use colored::*;
|
||||||
use riven::consts::*;
|
use riven::consts::*;
|
||||||
use riven::models::summoner_v4::*;
|
use riven::models::summoner_v4::*;
|
||||||
|
|
||||||
|
fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
|
||||||
fn validate_lugnutsk(s: Summoner, tag: &str) -> Result<(), String> {
|
rassert_eq!(s1.name, s2.name, "Names didn't match {}.", "");
|
||||||
rassert_eq!("LugnutsK", s.name,
|
rassert_eq!(s1.id, s2.id, "SummonerId didn't match {}.", "");
|
||||||
"LugnutsK name didn't match {}.", tag);
|
rassert_eq!(s1.account_id, s2.account_id, "AccountId didn't match {}.", "");
|
||||||
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +25,7 @@ async_tests!{
|
||||||
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lugnuts 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 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())?;
|
let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l2".to_owned())?;
|
||||||
validate_lugnutsk(l1, "l1")?;
|
validate_summoners(l1, l2)?;
|
||||||
validate_lugnutsk(l2, "l2")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
champion_getrotation: async {
|
champion_getrotation: async {
|
||||||
|
|
Loading…
Reference in a new issue