chore: fix create upload test (#1040)
* chore: fix create upload test * chore: fix test * chore: fmt
This commit is contained in:
parent
b8d8007f26
commit
81ee8c878a
1
dev.env
1
dev.env
|
|
@ -91,6 +91,7 @@ APPFLOWY_S3_ACCESS_KEY=${AWS_ACCESS_KEY}
|
||||||
APPFLOWY_S3_SECRET_KEY=${AWS_SECRET}
|
APPFLOWY_S3_SECRET_KEY=${AWS_SECRET}
|
||||||
APPFLOWY_S3_BUCKET=appflowy
|
APPFLOWY_S3_BUCKET=appflowy
|
||||||
#APPFLOWY_S3_REGION=us-east-1
|
#APPFLOWY_S3_REGION=us-east-1
|
||||||
|
APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api
|
||||||
|
|
||||||
# AppFlowy Cloud Mailer
|
# AppFlowy Cloud Mailer
|
||||||
# Note that smtps (TLS) is always required, even for ports other than 465
|
# Note that smtps (TLS) is always required, even for ports other than 465
|
||||||
|
|
|
||||||
|
|
@ -6,29 +6,6 @@ use collab_folder::ViewLayout;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::Duration;
|
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]
|
#[tokio::test]
|
||||||
async fn import_blog_post_test() {
|
async fn import_blog_post_test() {
|
||||||
// Step 1: Import the blog post zip
|
// Step 1: Import the blog post zip
|
||||||
|
|
@ -210,15 +187,15 @@ async fn upload_file(
|
||||||
upload_after_secs: Option<u64>,
|
upload_after_secs: Option<u64>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
|
let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
|
||||||
let mut url = client
|
let url = client
|
||||||
.api_client
|
.api_client
|
||||||
.create_import(&file_path)
|
.create_import(&file_path)
|
||||||
.await?
|
.await?
|
||||||
.presigned_url;
|
.presigned_url;
|
||||||
|
|
||||||
if url.contains("http://minio:9000") {
|
// if url.contains("http://minio:9000") {
|
||||||
url = url.replace("http://minio:9000", "http://localhost/minio");
|
// url = url.replace("http://minio:9000", "http://localhost/minio");
|
||||||
}
|
// }
|
||||||
|
|
||||||
if let Some(secs) = upload_after_secs {
|
if let Some(secs) = upload_after_secs {
|
||||||
tokio::time::sleep(Duration::from_secs(secs)).await;
|
tokio::time::sleep(Duration::from_secs(secs)).await;
|
||||||
|
|
@ -234,8 +211,14 @@ async fn upload_file(
|
||||||
// upload_after_secs: simulate the delay of uploading the file
|
// upload_after_secs: simulate the delay of uploading the file
|
||||||
async fn import_notion_zip_until_complete(name: &str) -> (TestClient, String) {
|
async fn import_notion_zip_until_complete(name: &str) -> (TestClient, String) {
|
||||||
let client = TestClient::new_user().await;
|
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;
|
let default_workspace_id = client.workspace_id().await;
|
||||||
|
|
||||||
// when importing a file, the workspace for the file should be created and it's
|
// when importing a file, the workspace for the file should be created and it's
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue