1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#![allow(unused_mut, unused_imports, unused_macros)]
extern crate hyper;
pub mod api;
#[cfg_attr(tarpaulin, skip)]
pub mod constants;
pub mod ddragon;
#[cfg_attr(tarpaulin, skip)]
#[allow(missing_docs)]
pub mod dto;
#[allow(missing_docs)]
pub mod error;
pub(crate) mod types;
pub(crate) mod utils;
pub use {
api::LeagueClient,
constants::{LanguageCode, RankedQueue, Region},
dto::api::*,
dto::ddragon::*,
};
#[cfg(test)]
mod tests {
use crate::{Summoner, LeagueClient, Region};
use std::time::Duration;
#[test]
#[cfg(feature = "async_std_rt")]
fn ensure_different_runtimes_work_with_lib() {
pretty_env_logger::try_init().unwrap_or(());
let lapi = LeagueClient::new(Region::RU).unwrap();
let sum = async_std::task::block_on(async {
lapi.get_summoner_by_name("Vetro").await.unwrap()
});
log::debug!("summoner from async_std: {:?}", sum);
assert_eq!("Vetro", &sum.name);
std::thread::sleep(Duration::from_secs(10));
}
#[test]
#[cfg(feature = "tokio_rt")]
fn ensure_different_runtimes_work_with_lib() {
pretty_env_logger::try_init().unwrap_or(());
let mut rt = tokio::runtime::Runtime::new().unwrap();
println!("in tokio rt");
let lapi = LeagueClient::new(Region::RU).unwrap();
let sum = rt.block_on(async {
let sum = lapi.get_summoner_by_name("Vetro").await.unwrap();
sum
});
println!("summoner from tokio: {:?}", sum);
assert_eq!("Vetro", &sum.name);
std::thread::sleep(Duration::from_secs(10));
}
#[test]
#[cfg(feature = "smol_rt")]
fn ensure_different_runtimes_work_with_lib() {
pretty_env_logger::try_init().unwrap_or(());
let lapi = LeagueClient::new(Region::RU).unwrap();
let sum = smol::run(async {
let sum = lapi.get_summoner_by_name("Vetro").await.unwrap();
sum
});
log::debug!("summoner from smol_rt: {:?}", sum);
assert_eq!("Vetro", &sum.name);
std::thread::sleep(Duration::from_secs(10));
}
}