#[macro_use] extern crate json;
#[macro_use] extern crate noir;
#[macro_use]
mod base_test;
test!();
#[test]
fn test_responses_provided_with_query_string() {
let actual = {
API::get("/responses/query")
.provide(responses![
EXAMPLE.get("/one")
.with_query(query!{
"key" => "value",
"array[]" => vec!["item1", "item2", "item3"],
"foo" => "bar",
"single" => vec!["item"]
})
])
.collect()
};
assert_pass!(actual);
}
#[test]
fn test_responses_provided_with_query_string_mismatch() {
let actual = {
API::get("/responses/query")
.provide(responses![
EXAMPLE.get("/two")
.with_query(query!{
"key" => "value",
"array[]" => vec!["item1", "item2", "item3"],
"foo" => "bar",
"single" => vec!["item"]
})
])
.collect()
};
assert_fail!(r#"
Response Failure: GET request to \"http://localhost:4000/responses/query\" returned
2 error(s)
1)
Request Failure: GET response provided for \"https://example.com/two?key=value&array%5B%5D=item1&array%5B%5D=item2&array%5B%5D=item3&foo=bar&single=item\" returned
1 error(s)
1.1) Expected a request for the response, but got
none.
2)
Request Failure: Unexpected GET request to \"https://example.com/one?key=value&array%5B%5D=item1&array%5B%5D=item2&array%5B%5D=item3&foo=bar&single=item\", no response was provided.
"#, actual);
}