From 4c618eb9393fde7882e656c57882f22273bdfe85 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Thu, 7 Oct 2021 10:10:19 -0700 Subject: [PATCH] Add more match-v5 tests --- riven/tests/tests_americas.rs | 4 ++-- riven/tests/tests_asia.rs | 40 +++++++++++++++++++++++++++++++++++ test.bash | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 riven/tests/tests_asia.rs diff --git a/riven/tests/tests_americas.rs b/riven/tests/tests_americas.rs index 28c23be..aaa5a2c 100644 --- a/riven/tests/tests_americas.rs +++ b/riven/tests/tests_americas.rs @@ -12,7 +12,7 @@ use riven::models::tournament_stub_v4::*; 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!{ 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))?; 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, 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."); } Ok(()) diff --git a/riven/tests/tests_asia.rs b/riven/tests/tests_asia.rs new file mode 100644 index 0000000..2a9058a --- /dev/null +++ b/riven/tests/tests_asia.rs @@ -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(()) + }, + } +} diff --git a/test.bash b/test.bash index 05ebdb7..256d707 100755 --- a/test.bash +++ b/test.bash @@ -1,2 +1,2 @@ #!/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