forked from mirror/Riven
1
0
Fork 0

Add more match-v5 tests

users/mingwei/unknown-variant-messy
Mingwei Samuel 2021-10-07 10:10:19 -07:00
parent ad1b4fd630
commit 4c618eb939
3 changed files with 43 additions and 3 deletions

View File

@ -12,7 +12,7 @@ use riven::models::tournament_stub_v4::*;
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS; const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
static MATCHES: [&'static str; 3] = [ "NA1_3923487226", "NA1_4049206905", "NA1_4052515784" ]; static MATCHES: [&'static str; 4] = [ "NA1_3923487226", "NA1_4049206905", "NA1_4052515784", "NA1_4062578191" ];
async_tests!{ async_tests!{
my_runner { my_runner {
@ -78,7 +78,7 @@ async_tests!{
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match timeline {} not found.", matche))?; let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match timeline {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id); rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants."); rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert_eq!(matche, format!("NA1_{}", m.info.game_id), "Match number ID should match."); rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", m.info.game_id), "Match number ID should match.");
rassert!(!m.info.frames.is_empty(), "Match timleine should have frames."); rassert!(!m.info.frames.is_empty(), "Match timleine should have frames.");
} }
Ok(()) Ok(())

40
riven/tests/tests_asia.rs Normal file
View File

@ -0,0 +1,40 @@
#![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: RegionalRoute = RegionalRoute::ASIA;
static MATCHES: [&'static str; 1] = [ "KR_5495121707" ];
async_tests!{
my_runner {
match_v5_get: async {
for matche in MATCHES {
let p = RIOT_API.match_v5().get_match(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert!(!m.info.teams.is_empty(), "Match should have teams.");
}
Ok(())
},
match_v5_get_timeline: async {
for matche in MATCHES {
let p = RIOT_API.match_v5().get_timeline(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match timeline {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", m.info.game_id), "Match number ID should match.");
rassert!(!m.info.frames.is_empty(), "Match timleine should have frames.");
}
Ok(())
},
}
}

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=trace cargo +nightly test --features nightly -- --nocapture RGAPI_KEY="$(cat apikey.txt)" RUST_BACKTRACE=1 RUST_LOG=riven=trace cargo +nightly test --features nightly $1 -- --nocapture