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
mod time;
use Client;
use api;
use error;
const ENV_KEY: &str = "PROXER_API_KEY";
#[test]
fn api_response() {
info!("creating client");
let mut client = match Client::with_env_key(ENV_KEY) {
None => return,
Some(client) => client,
};
info!("build request");
let req = api::info::GetFullEntry { id: 53 };
info!("send request");
let res = client.execute(req);
info!("request sent");
match res {
Err(e) => {
error!("error...");
eprintln!("response {:#?}", e);
match e {
error::Error::Api(e) => {
info!("api error");
match e.error() {
error::api::Errcode::NoApiPermissions => return,
_ => panic!("unexpected api error: {}", e),
}
}
error::Error::Json(e) => panic!("can't parse json: {}", e),
error::Error::Unknown => panic!("unknown error"),
_ => return,
}
}
Ok(r) => {
info!("Ok");
assert_eq!(r.medium, "animeseries");
}
}
}