From a50fb77fde6584c0c9701350697498e1ce24a3a8 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Mon, 2 Dec 2019 06:54:25 -0800 Subject: [PATCH] add live game test --- tests/tests_euw.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/tests_euw.rs b/tests/tests_euw.rs index 9ed4984..19704ec 100644 --- a/tests/tests_euw.rs +++ b/tests/tests_euw.rs @@ -25,6 +25,24 @@ async_tests!{ rassert!(s.len() >= 142, "Expected masteries: {}.", s.len()); Ok(()) }, + spectator_combo: async { + let featured_p = RIOT_API.spectator_v4().get_featured_games(Region::EUW); + let featured = featured_p.await.map_err(|e| e.to_string())?; + + rassert!(featured.game_list.len() > 0); + + let summoner_name = &featured.game_list[0].participants[0].summoner_name; + let summoner_p = RIOT_API.summoner_v4().get_by_summoner_name(Region::EUW, summoner_name); + let summoner = summoner_p.await.map_err(|e| e.to_string())?.ok_or("Failed to get summoner".to_owned())?; + + let livegame_p = RIOT_API.spectator_v4().get_current_game_info_by_summoner(Region::EUW, &summoner.id); + let livegame_o = livegame_p.await.map_err(|e| e.to_string())?; + if let Some(livegame) = livegame_o { + let participant_match = livegame.participants.iter().find(|p| p.summoner_name == *summoner_name); + rassert!(participant_match.is_some(), "Failed to find summoner in match: {}.", summoner_name); + } + Ok(()) + }, // // TFT tests. // tftleaguev1_getchallengerleague: async { // let p = RIOT_API.tft_league_v1().get_challenger_league(Region::EUW);