From 0f4d4e4b3c95dd4e2f44913e03fa54664b4248d2 Mon Sep 17 00:00:00 2001 From: Fu Zi Xiang Date: Fri, 12 Jan 2024 17:59:25 +0800 Subject: [PATCH] fix: large file test case --- libs/client-api/src/http.rs | 2 +- tests/workspace/blob/put_and_get.rs | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/client-api/src/http.rs b/libs/client-api/src/http.rs index b303e432..a90126a7 100644 --- a/libs/client-api/src/http.rs +++ b/libs/client-api/src/http.rs @@ -1096,7 +1096,7 @@ impl Client { .send() .await?; log_request_id(&resp); - Ok(()) + AppResponse::<()>::from_response(resp).await?.into_error() } /// Only expose this method for testing diff --git a/tests/workspace/blob/put_and_get.rs b/tests/workspace/blob/put_and_get.rs index 6c2b7686..8e83bac6 100644 --- a/tests/workspace/blob/put_and_get.rs +++ b/tests/workspace/blob/put_and_get.rs @@ -42,19 +42,19 @@ async fn put_and_get() { } // TODO: fix inconsistent behavior due to different error handling with nginx -// #[tokio::test] -// async fn put_giant_file() { -// let (c1, _user1) = generate_unique_registered_user_client().await; -// let workspace_id = workspace_id_from_client(&c1).await; -// let mime = mime::TEXT_PLAIN_UTF_8; -// let file_id = uuid::Uuid::new_v4().to_string(); -// -// let url = c1.get_blob_url(&workspace_id, &file_id); -// let data = vec![0; 10 * 1024 * 1024 * 1024]; -// let error = c1.put_blob(&url, data, &mime).await.unwrap_err(); -// -// assert_eq!(error.code, ErrorCode::PayloadTooLarge); -// } +#[tokio::test] +async fn put_giant_file() { + let (c1, _user1) = generate_unique_registered_user_client().await; + let workspace_id = workspace_id_from_client(&c1).await; + let mime = mime::TEXT_PLAIN_UTF_8; + let file_id = uuid::Uuid::new_v4().to_string(); + + let url = c1.get_blob_url(&workspace_id, &file_id); + let data = vec![0; 10 * 1024 * 1024 * 1024]; + let error = c1.put_blob(&url, data, &mime).await.unwrap_err(); + + assert_eq!(error.code, ErrorCode::PayloadTooLarge); +} #[tokio::test] async fn put_and_put_and_get() {