1
0
Fork 0
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:
Dominic 2020-05-08 18:39:11 +02:00
parent 4bf0bd7b09
commit e05f9bb963
Signed by: msrd0
GPG key ID: DCC8C247452E98F9
23 changed files with 473 additions and 28 deletions

37
tests/util/mod.rs Normal file
View 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);
}