2021-05-22 04:59:51 +00:00
|
|
|
mod testutils;
|
|
|
|
use riven::consts::*;
|
2023-10-18 05:57:10 +00:00
|
|
|
use riven::models::tournament_stub_v5::*;
|
2024-01-21 03:41:46 +00:00
|
|
|
use testutils::*;
|
2021-05-22 04:59:51 +00:00
|
|
|
|
|
|
|
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
|
|
|
|
|
2024-03-08 17:39:36 +00:00
|
|
|
static MATCHES: &[&str] = &["NA1_4924008147"];
|
2021-09-28 02:38:20 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
/// Account-v1
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn account_v1_getbyriotid_getbypuuid() -> Result<(), String> {
|
|
|
|
// Game name is case and whitespace insensitive.
|
|
|
|
// But tag cannot have spaces. (Is it case sensitive?).
|
2024-02-24 17:46:11 +00:00
|
|
|
let account_tag = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.account_v1()
|
|
|
|
.get_by_riot_id(ROUTE, "Lug nuts K", "000")
|
|
|
|
.await
|
|
|
|
.map_err(|e| format!("Failed to get account by riot ID: {}", e))?
|
|
|
|
.ok_or("Riot account not found!".to_owned())?;
|
2023-11-15 18:46:27 +00:00
|
|
|
|
2024-02-24 17:46:11 +00:00
|
|
|
let account_puuid = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.account_v1()
|
|
|
|
.get_by_puuid(ROUTE, &account_tag.puuid)
|
|
|
|
.await
|
|
|
|
.map_err(|e| format!("Failed to get account by PUUID: {}", e))?;
|
2023-11-15 18:46:27 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
let _ = account_puuid;
|
2023-11-15 18:46:27 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
2023-11-15 18:46:27 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
/// Tournament stub test.
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tournamentstub() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let ts = riot_api().tournament_stub_v5();
|
2024-02-24 17:28:33 +00:00
|
|
|
let provider_id = ts
|
|
|
|
.register_provider_data(
|
|
|
|
ROUTE,
|
|
|
|
&ProviderRegistrationParametersV5 {
|
2023-10-18 05:57:10 +00:00
|
|
|
region: PlatformRoute::NA1.as_region_str().to_owned(),
|
|
|
|
url: "https://github.com/MingweiSamuel/Riven".to_owned(),
|
2024-02-24 17:28:33 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.map_err(|e| e.to_string())?;
|
2021-05-22 04:59:51 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
println!("provider_id: {}", provider_id);
|
2021-05-22 04:59:51 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
let tournament_id = ts
|
|
|
|
.register_tournament(
|
|
|
|
ROUTE,
|
|
|
|
&TournamentRegistrationParametersV5 {
|
2023-10-18 05:57:10 +00:00
|
|
|
name: Some("Riven Tourney :)".to_owned()),
|
|
|
|
provider_id,
|
2024-02-24 17:28:33 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.map_err(|e| e.to_string())?;
|
2021-05-22 04:59:51 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
println!("tournament_id: {}", tournament_id);
|
2021-05-22 04:59:51 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
let codes_result = ts
|
|
|
|
.create_tournament_code(
|
|
|
|
ROUTE,
|
|
|
|
&TournamentCodeParametersV5 {
|
2023-10-18 05:57:10 +00:00
|
|
|
map_type: "SUMMONERS_RIFT".to_owned(),
|
|
|
|
metadata: Some("eW91IGZvdW5kIHRoZSBzZWNyZXQgbWVzc2FnZQ==".to_owned()),
|
|
|
|
pick_type: "TOURNAMENT_DRAFT".to_owned(),
|
|
|
|
spectator_type: "ALL".to_owned(),
|
|
|
|
team_size: 5,
|
|
|
|
allowed_participants: None,
|
|
|
|
enough_players: false,
|
2024-02-24 17:28:33 +00:00
|
|
|
},
|
|
|
|
tournament_id as i64,
|
|
|
|
Some(300),
|
|
|
|
)
|
|
|
|
.await;
|
2021-05-22 04:59:51 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
match codes_result {
|
|
|
|
Ok(codes) => {
|
|
|
|
rassert_eq!(300, codes.len());
|
|
|
|
println!("codes: {}", codes.join(", "));
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
Err(mut e) => {
|
|
|
|
if let Some(response) = e.take_response() {
|
|
|
|
eprintln!("{:?}", response.text().await);
|
2023-10-18 05:57:10 +00:00
|
|
|
}
|
2024-02-24 17:28:33 +00:00
|
|
|
Err(e.to_string())
|
|
|
|
}
|
2021-05-22 04:59:51 +00:00
|
|
|
}
|
|
|
|
}
|
2024-02-24 17:28:33 +00:00
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn match_v5_get_test() -> Result<(), String> {
|
|
|
|
match_v5_get(ROUTE, MATCHES).await
|
|
|
|
}
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn match_v5_get_timeline_test() -> Result<(), String> {
|
|
|
|
match_v5_get_timeline(ROUTE, MATCHES).await
|
|
|
|
}
|