#[macro_use] extern crate json;
#[macro_use] extern crate noir;
#[macro_use]
mod base_test;
test!();
#[derive(Copy, Clone, Default)]
pub struct TimeoutAPI;
impl HttpApi for TimeoutAPI {
fn hostname(&self) -> &'static str {
"localhost"
}
fn port(&self) -> u16 {
4001
}
fn start(&self) {
// Do nothing so we timeout
}
}
#[test]
fn test_api_start_timeout() {
let actual = {
TimeoutAPI::get("/").collect()
};
assert_fail!(r#"
Noir Api Failure: Server for \"http://localhost:4001\" did not respond within 1000ms.
"#, actual);
}
#[test]
fn test_api_start_multiple() {
let actual = {
API::get("/").collect()
};
assert_pass!(actual);
}
#[test]
fn test_api_request_timeout() {
let actual = {
API::get("/timeout").collect()
};
assert_fail!(r#"
Response Failure: GET request to \"http://localhost:4000/timeout\" returned
1 error(s)
1)
Noir Api Failure: No response within 1000ms.
"#, actual);
}