mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-23 13:02:28 +00:00
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
use gotham::{
|
|
hyper::Body,
|
|
test::TestServer
|
|
};
|
|
use mime::Mime;
|
|
|
|
pub fn test_get_response(server : &TestServer, path : &str, expected : &[u8])
|
|
{
|
|
let res = server.client().get(path).perform().unwrap().read_body().unwrap();
|
|
let body : &[u8] = res.as_ref();
|
|
assert_eq!(body, expected);
|
|
}
|
|
|
|
pub fn test_post_response<B>(server : &TestServer, path : &str, body : B, mime : Mime, expected : &[u8])
|
|
where
|
|
B : Into<Body>
|
|
{
|
|
let res = server.client().post(path, body, mime).perform().unwrap().read_body().unwrap();
|
|
let body : &[u8] = res.as_ref();
|
|
assert_eq!(body, expected);
|
|
}
|
|
|
|
pub fn test_put_response<B>(server : &TestServer, path : &str, body : B, mime : Mime, expected : &[u8])
|
|
where
|
|
B : Into<Body>
|
|
{
|
|
let res = server.client().put(path, body, mime).perform().unwrap().read_body().unwrap();
|
|
let body : &[u8] = res.as_ref();
|
|
assert_eq!(body, expected);
|
|
}
|
|
|
|
pub fn test_delete_response(server : &TestServer, path : &str, expected : &[u8])
|
|
{
|
|
let res = server.client().delete(path).perform().unwrap().read_body().unwrap();
|
|
let body : &[u8] = res.as_ref();
|
|
assert_eq!(body, expected);
|
|
}
|