From f199d02d81d97c5463a51dfe632d0ff78f6e468f Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 13 Jun 2026 19:26:41 -0400 Subject: [PATCH] Test changes --- tests/test.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/test.rs b/tests/test.rs index d947449..47042a3 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -157,7 +157,43 @@ pub async fn bearer_auth() -> String { format!("Bearer {token}") } -mod request {} +mod request { + // use common_multipart_rfc7578::client::multipart::{ + // Body as MultipartBody, Form as MultipartForm, + // }; + use tower::ServiceExt; + + pub async fn create_contact( + app: &axum::Router, + ) -> Result { + let payload = serde_json::json!({ + "phone_number": super::TEST_CONTACT_PHONE_NUMBER, + "user_id": super::TEST_USER_ID, + }); + // Create multipart form + // let mut form = MultipartForm::default(); + // let _ = form.add_file("flac", "tests/I/track01.flac"); + + // Create request + // let content_type = form.content_type(); + // let body = MultipartBody::from(form); + let req = axum::http::Request::builder() + .method(axum::http::Method::POST) + .uri(textsender_api::caller::endpoints::ADD_CONTACT) + .header(axum::http::header::CONTENT_TYPE, "application/json") + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) + .body(axum::body::Body::from(payload.to_string())) + // .body(axum::body::Body::from_stream(body)) + .unwrap(); + app.clone().oneshot(req).await + } +} + +/// Test contact phone number +pub const TEST_CONTACT_PHONE_NUMBER: &str = "+10123456789"; #[tokio::test] async fn test_create_contact() {