mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 06:54:46 +00:00
a whole bunch of tests for the method macros
This commit is contained in:
parent
4bf0bd7b09
commit
e05f9bb963
23 changed files with 473 additions and 28 deletions
37
tests/util/mod.rs
Normal file
37
tests/util/mod.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue