Add tests for headers and response body

master
Michal Baumgartner 2020-04-19 22:09:17 +02:00 committed by Mingwei Samuel
parent d5494ba442
commit 169fa50f63
1 changed files with 25 additions and 0 deletions

View File

@ -49,6 +49,31 @@ async_tests!{
}
Ok(())
},
inspecting_response_and_headers_on_error: async {
let sum = RIOT_API.summoner_v4().get_by_puuid(Region::EUW, "clearly not a puuid").await;
match sum {
Ok(_summoner) => rassert!(false, "Should not have succeeded"),
Err(error) => {
match error.headers() {
Some(headers) => {
rassert!(headers.len() > 0, "Invalid headers received: {:?}", error);
rassert!(headers.contains_key("x-app-rate-limit"), "Invalid headers received: {:?}", error);
rassert!(headers.contains_key("x-method-rate-limit"), "Invalid headers received: {:?}", error);
},
None => rassert!(false, "Headers shouldn't be empty"),
}
match error.response_body() {
Some(body) => {
rassert!(body.len() > 0, "Invalid body received: {:?}", error);
},
None => rassert!(false, "The response body shouldn't be empty"),
}
}
};
Ok(())
},
// // TFT tests.
// tftleaguev1_getchallengerleague: async {
// let p = RIOT_API.tft_league_v1().get_challenger_league(Region::EUW);