#[macro_use] extern crate json; #[macro_use] extern crate noir; #[macro_use] mod base_test; test!(); // Multiple Errors ------------------------------------------------------------ #[test] fn test_multiple_errors_raw_body() { let actual = { API::get("/status/404") .expected_status(StatusCode::Ok) .expected_header(Server("Foo".to_string())) .expected_body("Hello World") .collect() }; assert_fail!(r#"
Response Failure: GET request to \"http://localhost:4000/status/404\" returned
3 error(s)
1) Response status code does not match value, expected: \"200 OK\" but got: \"
404 Not Found\"
2) Response header \"Server\" was expected to be present, but
is missing.
3) Response raw body data does not match, expected the following 11 bytes: [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64] but got the following
0 bytes instead: [] "#, actual); } #[test] fn test_multiple_errors_text_body() { let actual = { API::post("/echo") .with_header(ContentType( Mime(TopLevel::Text, SubLevel::Plain, vec![]) )) .with_body("Hello World Message") .expected_status(StatusCode::NotFound) .expected_header(Server("Foo".to_string())) .expected_body("Hello World") .collect() }; assert_fail!(r#"
Response Failure: POST request to \"http://localhost:4000/echo\" returned
3 error(s)
1) Response status code does not match value, expected: \"404 Not Found\" but got: \"
200 OK\"
2) Response header \"Server\" was expected to be present, but
is missing.
3) Response does not match, expected: \"Hello World\" but got: \"
Hello World Message\" difference: \"Hello World Message\" "#, actual); }