feat: test body helper
This commit is contained in:
parent
931b7e159d
commit
187f13a938
@ -20,6 +20,7 @@ pub use test_requests::test_delete;
|
||||
pub use test_requests::test_get;
|
||||
pub use test_requests::test_post;
|
||||
pub use test_requests::RequestConfig;
|
||||
pub use test_requests::read_body;
|
||||
|
||||
use crate::create_app;
|
||||
|
||||
@ -125,3 +126,13 @@ fn build_test_db_name(base_name: &str) -> String {
|
||||
.collect();
|
||||
format!("{}_{}", base_name, test_db_suffix).to_lowercase()
|
||||
}
|
||||
|
||||
macro_rules! assert_snapshot {
|
||||
($x:expr) => {
|
||||
insta::with_settings!({snapshot_path => "../../../snapshots"}, {
|
||||
insta::assert_snapshot!($x);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use assert_snapshot;
|
||||
|
@ -70,6 +70,13 @@ where
|
||||
login_resp.response().cookies().next().unwrap().into_owned()
|
||||
}
|
||||
|
||||
pub async fn read_body<M>(response: ServiceResponse<M>) -> String
|
||||
where
|
||||
M: MessageBody,
|
||||
{
|
||||
String::from_utf8(test::read_body(response).await.to_vec()).unwrap()
|
||||
}
|
||||
|
||||
pub async fn test_get<T, R>(
|
||||
pool: &Pool<Postgres>,
|
||||
app: T,
|
||||
|
Loading…
x
Reference in New Issue
Block a user