2017-01-16 16:34:19 +00:00
|
|
|
use super::rocket;
|
2017-06-06 20:41:04 +00:00
|
|
|
use rocket::local::Client;
|
2017-01-16 16:34:19 +00:00
|
|
|
use rocket::http::Status;
|
|
|
|
|
|
|
|
fn test(uri: &str, expected: &str) {
|
2017-06-06 20:41:04 +00:00
|
|
|
let client = Client::new(rocket()).unwrap();
|
|
|
|
let mut res = client.get(uri).dispatch();
|
2017-04-14 08:59:28 +00:00
|
|
|
assert_eq!(res.body_string(), Some(expected.into()));
|
2017-01-16 16:34:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_404(uri: &str) {
|
2017-06-06 20:41:04 +00:00
|
|
|
let client = Client::new(rocket()).unwrap();
|
|
|
|
let res = client.get(uri).dispatch();
|
2017-01-16 16:34:19 +00:00
|
|
|
assert_eq!(res.status(), Status::NotFound);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_people() {
|
|
|
|
test("/people/7f205202-7ba1-4c39-b2fc-3e630722bf9f", "We found: Lacy");
|
|
|
|
test("/people/4da34121-bc7d-4fc1-aee6-bf8de0795333", "We found: Bob");
|
|
|
|
test("/people/ad962969-4e3d-4de7-ac4a-2d86d6d10839", "We found: George");
|
2017-06-06 20:41:04 +00:00
|
|
|
test("/people/e18b3a5c-488f-4159-a240-2101e0da19fd",
|
|
|
|
"Person not found for UUID: e18b3a5c-488f-4159-a240-2101e0da19fd");
|
2017-01-16 16:34:19 +00:00
|
|
|
test_404("/people/invalid_uuid");
|
|
|
|
}
|