use actix_http::Request; use actix_web::dev::{Service, ServiceResponse}; use actix_web::{test, Error}; use serde::de::DeserializeOwned; use serde_json::Value; use crate::helpers::error_response::ErrorResponse; use crate::helpers::handle_response::handle_response; pub async fn create_request( web_app: &T1, collection_name: &String, data: Value, secret_code: &String, ) -> Result where T1: Service, T2: DeserializeOwned, { let req = test::TestRequest::post() .uri(&format!("/api/collections/{collection_name}")) .insert_header(("authorization", format!("Bearer {secret_code}"))) .set_json(data) .to_request(); let resp = web_app.call(req).await.unwrap(); handle_response(resp).await }