style: cargo fmt --all
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
use application::testing::{InMemoryJobBatchRepository, InMemoryJobRepository, StubEventPublisher};
|
||||
use application::processing::{CompleteJobCommand, CompleteJobHandler};
|
||||
use application::testing::{InMemoryJobBatchRepository, InMemoryJobRepository, StubEventPublisher};
|
||||
use domain::entities::{Job, JobBatch, JobStatus, JobType};
|
||||
use domain::events::DomainEvent;
|
||||
use domain::ports::{JobBatchRepository, JobRepository};
|
||||
use domain::value_objects::StructuredData;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[tokio::test]
|
||||
async fn completes_job() {
|
||||
@@ -18,10 +18,13 @@ async fn completes_job() {
|
||||
job_repo.save(&job).await.unwrap();
|
||||
|
||||
let handler = CompleteJobHandler::new(job_repo.clone(), batch_repo.clone(), event_pub.clone());
|
||||
let result = handler.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
}).await.unwrap();
|
||||
let result = handler
|
||||
.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(result.status, JobStatus::Completed);
|
||||
assert!(result.result_data.is_some());
|
||||
@@ -37,17 +40,19 @@ async fn completes_job_and_updates_batch() {
|
||||
let batch_id = batch.batch_id;
|
||||
batch_repo.save(&batch).await.unwrap();
|
||||
|
||||
let mut job = Job::new(JobType::ExtractMetadata, 5, StructuredData::new())
|
||||
.with_batch(batch_id);
|
||||
let mut job = Job::new(JobType::ExtractMetadata, 5, StructuredData::new()).with_batch(batch_id);
|
||||
job.start().unwrap();
|
||||
let job_id = job.job_id;
|
||||
job_repo.save(&job).await.unwrap();
|
||||
|
||||
let handler = CompleteJobHandler::new(job_repo.clone(), batch_repo.clone(), event_pub.clone());
|
||||
handler.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
}).await.unwrap();
|
||||
handler
|
||||
.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let updated_batch = batch_repo.find_by_id(&batch_id).await.unwrap().unwrap();
|
||||
assert_eq!(updated_batch.completed_count, 1);
|
||||
@@ -65,10 +70,13 @@ async fn publishes_event() {
|
||||
job_repo.save(&job).await.unwrap();
|
||||
|
||||
let handler = CompleteJobHandler::new(job_repo.clone(), batch_repo.clone(), event_pub.clone());
|
||||
handler.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
}).await.unwrap();
|
||||
handler
|
||||
.execute(CompleteJobCommand {
|
||||
job_id,
|
||||
result: StructuredData::new(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let events = event_pub.published().await;
|
||||
assert_eq!(events.len(), 1);
|
||||
|
||||
Reference in New Issue
Block a user