Skip to content

Commit

Permalink
chore: fix create upload test (#1040)
Browse files Browse the repository at this point in the history
* chore: fix create upload test

* chore: fix test

* chore: fmt
  • Loading branch information
appflowy authored Feb 5, 2025
1 parent b8d8007 commit 81ee8c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
1 change: 1 addition & 0 deletions dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ APPFLOWY_S3_ACCESS_KEY=${AWS_ACCESS_KEY}
APPFLOWY_S3_SECRET_KEY=${AWS_SECRET}
APPFLOWY_S3_BUCKET=appflowy
#APPFLOWY_S3_REGION=us-east-1
APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api

# AppFlowy Cloud Mailer
# Note that smtps (TLS) is always required, even for ports other than 465
Expand Down
41 changes: 12 additions & 29 deletions tests/workspace/import_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ use collab_folder::ViewLayout;
use std::path::PathBuf;
use std::time::Duration;

// #[tokio::test]
// async fn import_blog_post_four_times_test() {
// let mut handles = vec![];
// // Simulate 4 clients, each uploading 3 files concurrently.
// for _ in 0..4 {
// let handle = tokio::spawn(async {
// let client = TestClient::new_user().await;
// for _ in 0..3 {
// let _ = upload_file(&client, "blog_post.zip", None).await.unwrap();
// }
//
// // the default concurrency limit is 3, so the fourth import should fail
// upload_file(&client, "blog_post.zip", None).await.unwrap();
// wait_until_num_import_task_complete(&client, 3).await;
// });
// handles.push(handle);
// }
//
// for result in join_all(handles).await {
// result.unwrap();
// }
// }

#[tokio::test]
async fn import_blog_post_test() {
// Step 1: Import the blog post zip
Expand Down Expand Up @@ -210,15 +187,15 @@ async fn upload_file(
upload_after_secs: Option<u64>,
) -> Result<(), Error> {
let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
let mut url = client
let url = client
.api_client
.create_import(&file_path)
.await?
.presigned_url;

if url.contains("http://minio:9000") {
url = url.replace("http://minio:9000", "http://localhost/minio");
}
// if url.contains("http://minio:9000") {
// url = url.replace("http://minio:9000", "http://localhost/minio");
// }

if let Some(secs) = upload_after_secs {
tokio::time::sleep(Duration::from_secs(secs)).await;
Expand All @@ -234,8 +211,14 @@ async fn upload_file(
// upload_after_secs: simulate the delay of uploading the file
async fn import_notion_zip_until_complete(name: &str) -> (TestClient, String) {
let client = TestClient::new_user().await;
let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
client.api_client.import_file(&file_path).await.unwrap();

// Uncomment the following lines to use the predicated upload file API.
// Currently, we use `upload_file` to send a file to appflowy_worker, which then
// processes the upload task.
// let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
// client.api_client.import_file(&file_path).await.unwrap();
upload_file(&client, name, None).await.unwrap();

let default_workspace_id = client.workspace_id().await;

// when importing a file, the workspace for the file should be created and it's
Expand Down

0 comments on commit 81ee8c8

Please sign in to comment.