reanalyze removal
This commit is contained in:
@@ -56,12 +56,12 @@ struct DocumentDownload {
|
||||
filename: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct BulkReanalyze {
|
||||
queued: usize,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct BulkMoveResult {
|
||||
updated: usize,
|
||||
}
|
||||
@@ -318,97 +318,6 @@ async fn duplicate_and_restore_document() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn bulk_reanalyze_documents() -> Result<()> {
|
||||
let _lock = acquire_db_lock().await;
|
||||
let app = TestApp::new().await?;
|
||||
|
||||
let password = "bulkpass";
|
||||
app.insert_user("alex", password, "admin").await?;
|
||||
let token = app.login_token("alex", password).await?;
|
||||
|
||||
app.clear_jobs().await?;
|
||||
|
||||
let first_bytes = b"first doc";
|
||||
let first = app
|
||||
.upload_document(
|
||||
"/api/documents",
|
||||
"first.txt",
|
||||
"text/plain",
|
||||
first_bytes,
|
||||
None,
|
||||
&token,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(first.status(), StatusCode::CREATED);
|
||||
let first_body = body_to_vec(first.into_body()).await?;
|
||||
let first_detail: DocumentDetail = serde_json::from_slice(&first_body)?;
|
||||
|
||||
let second_bytes = b"second doc";
|
||||
let second = app
|
||||
.upload_document(
|
||||
"/api/documents",
|
||||
"second.txt",
|
||||
"text/plain",
|
||||
second_bytes,
|
||||
None,
|
||||
&token,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(second.status(), StatusCode::CREATED);
|
||||
let second_body = body_to_vec(second.into_body()).await?;
|
||||
let second_detail: DocumentDetail = serde_json::from_slice(&second_body)?;
|
||||
|
||||
app.clear_jobs().await?;
|
||||
|
||||
let response = app
|
||||
.post_json(
|
||||
"/api/documents/reanalyze",
|
||||
&serde_json::json!({}),
|
||||
Some(&token),
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(response.status(), StatusCode::ACCEPTED);
|
||||
let body = body_to_vec(response.into_body()).await?;
|
||||
let bulk: BulkReanalyze = serde_json::from_slice(&body)?;
|
||||
assert_eq!(bulk.queued, 2);
|
||||
|
||||
let jobs = app.jobs_by_type("analyze-document").await?;
|
||||
assert_eq!(jobs.len(), 2);
|
||||
let mut payload_docs = Vec::new();
|
||||
for job in jobs {
|
||||
let payload: AnalyzeJobPayload = serde_json::from_value(job.payload)?;
|
||||
assert!(payload.force);
|
||||
payload_docs.push((payload.document_id, payload.document_version_id));
|
||||
}
|
||||
|
||||
let mut expected = vec![
|
||||
(
|
||||
first_detail.document.id,
|
||||
first_detail
|
||||
.document
|
||||
.current_version
|
||||
.as_ref()
|
||||
.expect("first current version")
|
||||
.id,
|
||||
),
|
||||
(
|
||||
second_detail.document.id,
|
||||
second_detail
|
||||
.document
|
||||
.current_version
|
||||
.as_ref()
|
||||
.expect("second current version")
|
||||
.id,
|
||||
),
|
||||
];
|
||||
payload_docs.sort();
|
||||
expected.sort();
|
||||
assert_eq!(payload_docs, expected);
|
||||
|
||||
app.cleanup().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn bulk_move_documents_to_folder() -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user